home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / gnustuff / tos / updates / update31.zoo / lib / diffs < prev   
Encoding:
Text File  |  1993-05-29  |  90.5 KB  |  3,663 lines

  1. ===================================================================
  2. RCS file: /net/acae127/home/bammi/etc/src/master/atari/lib/Changelo,v
  3. retrieving revision 1.93
  4. diff -c -r1.93 Changelo
  5. *** 1.93    1993/05/21 12:52:46
  6. --- Changelo    1993/05/29 20:26:25
  7. ***************
  8. *** 3730,3732 ****
  9. --- 3730,3767 ----
  10.       Fixed sign for retinf, and retzero.
  11.   
  12.   ---------------------------- Patchlevel 89 ---------------------------
  13. +     michal did a tremendous amount of job tracking down modf and
  14. +     fixing the following. thanks michal.
  15. +     Wed May 26 20:35:34 1993  Michal Jaegermann  (michal at smok)
  16. +     * fixed norm_df and norm_sf not to set errno when processing
  17. +       legitimate zero argument
  18. +     * fixed wrong error codes and made sure that future changes
  19. +       in errno.h will be automatically reflected;
  20. +       this involves changes in errbase.h and errno.h
  21. +     * removed unused code from _divsf3.cpp
  22. +     * corrected bug in setting sign of Inf in _truncdf.cpp
  23. +     * made zeros returned from frexp and ldexp consistenly signed
  24. +       (they were signed or unsigned, depending on a way they were
  25. +        calculated)
  26. +     * renamed _cmpdf2.s to _cmpdf2.cpp and _cmpsf2.s to _cmpsf2.cpp
  27. +       and added preprocessor directives to split them into separate
  28. +       objects while compiling (required change in mincl)
  29. +     * replaced 68000 code for modf() with totally new, shorter and
  30. +       much faster version
  31. +     * added Olaf Flebbe fixes for sign of 0 in multiplication routines
  32. +     * general code cleanup all over the place in floating point support
  33. +       routines
  34. + scanf.c:: ++jrb
  35. +     fix bug reported by warwick, when "%Ns", the test for the end of
  36. +     the %s loop was incorrect. (left off 1 char too soon).
  37. +     added some decls for non ansi platforms.
  38. +     use long double type only when __M68881__ not with soft float.
  39. +     out soft float stuff knows nothing about long doubles.
  40. + ---------------------------- Patchlevel 90 ---------------------------
  41. ===================================================================
  42. RCS file: /net/acae127/home/bammi/etc/src/master/atari/lib/PatchLev.h,v
  43. retrieving revision 1.65
  44. diff -c -r1.65 PatchLev.h
  45. *** 1.65    1993/05/21 12:52:51
  46. --- PatchLev.h    1993/05/29 20:26:29
  47. ***************
  48. *** 1,5 ****
  49.   
  50. ! #define    PatchLevel "89"
  51.   
  52.   /*
  53.    *
  54. --- 1,5 ----
  55.   
  56. ! #define    PatchLevel "90"
  57.   
  58.   /*
  59.    *
  60. ===================================================================
  61. RCS file: /net/acae127/home/bammi/etc/src/master/atari/lib/fscanf.c,v
  62. retrieving revision 1.9
  63. diff -c -r1.9 fscanf.c
  64. *** 1.9    1992/01/29 20:58:29
  65. --- fscanf.c    1993/05/29 20:26:32
  66. ***************
  67. *** 5,11 ****
  68.   #include <compiler.h>
  69.   #endif
  70.   
  71. ! #ifdef sun
  72.   # define fungetc ungetc
  73.   #endif
  74.   
  75. --- 5,11 ----
  76.   #include <compiler.h>
  77.   #endif
  78.   
  79. ! #if defined(sun) || defined(__hpux)
  80.   # define fungetc ungetc
  81.   #endif
  82.   
  83. ===================================================================
  84. RCS file: /net/acae127/home/bammi/etc/src/master/atari/lib/mincl,v
  85. retrieving revision 1.27
  86. diff -c -r1.27 mincl
  87. *** 1.27    1993/05/21 12:52:54
  88. --- mincl    1993/05/29 20:26:34
  89. ***************
  90. *** 1,6 ****
  91.   #
  92.   # GCC specific stuff
  93. ! GLIB1 = _addsubd.o _addsubs.o _cmpdf2.o _cmpsf2.o _divdf3.o _divmods.o \
  94.       _divsf3.o _extends.o _fixdfsi.o _fxunsd.o _fltsi.o \
  95.       _muldf3.o _mulsf3.o _mulsi3.o _negdf2.o _negsf2.o _normdf.o _normsf.o \
  96.       _truncdf.o _udivmod.o _umulsi3.o _fixsfsi.o _fltsisf.o _isnan.o
  97. --- 1,9 ----
  98.   #
  99.   # GCC specific stuff
  100. ! FCOMPD = _eqdf2.o _gtdf2.o _ledf2.o _gedf2.o _ltdf2.o
  101. ! FCOMPS = _eqsf2.o _gtsf2.o _lesf2.o _gesf2.o _ltsf2.o
  102. ! GLIB1 = _addsubd.o _addsubs.o _divdf3.o _divmods.o \
  103.       _divsf3.o _extends.o _fixdfsi.o _fxunsd.o _fltsi.o \
  104.       _muldf3.o _mulsf3.o _mulsi3.o _negdf2.o _negsf2.o _normdf.o _normsf.o \
  105.       _truncdf.o _udivmod.o _umulsi3.o _fixsfsi.o _fltsisf.o _isnan.o
  106. ***************
  107. *** 12,18 ****
  108.       _caps_New.o _builtin_del.o _trampoline.o __main.o _ctor_list.o \
  109.       _dtor_list.o _ffsdi2.o
  110.   
  111. ! GCC=     $(GLIB1) $(GLIB2) \
  112.       ldexp.o frexp.o modf.o alloca.o setjmp.o osbind.o\
  113.       linea.o  alglobal.o sysvar.o gmon.o screen.o stksiz.o binmode.o \
  114.       bblink.o defmode.o
  115. --- 15,21 ----
  116.       _caps_New.o _builtin_del.o _trampoline.o __main.o _ctor_list.o \
  117.       _dtor_list.o _ffsdi2.o
  118.   
  119. ! GCC=     $(GLIB1) $(GLIB2) $(FCOMPD) $(FCOMPS)\
  120.       ldexp.o frexp.o modf.o alloca.o setjmp.o osbind.o\
  121.       linea.o  alglobal.o sysvar.o gmon.o screen.o stksiz.o binmode.o \
  122.       bblink.o defmode.o
  123. ***************
  124. *** 86,91 ****
  125. --- 89,100 ----
  126.   #
  127.   # Assembler stuff that needs to be preprocessed by cpp
  128.   #
  129. + $(FCOMPD): %.o: _cmpdf2.cpp
  130. +     $(CC) $(PPFLAGS) -DL$* -c $< -o $@
  131. + $(FCOMPS): %.o: _cmpsf2.cpp
  132. +     $(CC) $(PPFLAGS) -DL$* -c $< -o $@
  133.   %.o : %.cpp
  134.       $(CC) $(PPFLAGS) -c $<
  135.   
  136. ===================================================================
  137. RCS file: /net/acae127/home/bammi/etc/src/master/atari/lib/scanf.c,v
  138. retrieving revision 1.15
  139. diff -c -r1.15 scanf.c
  140. *** 1.15    1992/10/09 20:32:44
  141. --- scanf.c    1993/05/29 20:26:36
  142. ***************
  143. *** 39,44 ****
  144. --- 39,45 ----
  145.   #include <stdio.h>
  146.   #include <stdlib.h>
  147.   #include <string.h>
  148. + #include <compiler.h>
  149.   
  150.   /* the code assumes this definition, note: traditional <ctype> def
  151.    * of tolower will break the code. Ansi def should be ok.
  152. ***************
  153. *** 70,75 ****
  154. --- 71,78 ----
  155.   #define input_error()    return( done < 1 ? EOF : done )
  156.   #define    memory_error()    return((errno = ENOMEM), EOF)
  157.   
  158. + __EXTERN long int strtol __PROTO((const char *nptr, char **endptr, int base));
  159. + __EXTERN double strtod __PROTO((const char *s, char **endptr));
  160.   
  161.   /* Read formatted input from S according to the format string
  162.      FORMAT, using the argument list in ARG.
  163. ***************
  164. *** 110,116 ****
  165. --- 113,123 ----
  166.       unsigned long int unum;
  167.   #if FLOATS
  168.       /* Floating-point holding variable.  */
  169. + # ifdef __M68881__
  170.       long double fp_num;
  171. + # else
  172. +     double fp_num;
  173. + # endif
  174.   #endif
  175.       /* Character-buffer pointer.  */
  176.       register char *str;
  177. ***************
  178. *** 285,293 ****
  179.               break;
  180.           if (do_assign)
  181.               *str++ = c;
  182. !         if (width > 0 && --width == 0)
  183. !             break;
  184. !         } while (inchar() != EOF);
  185.           
  186.           if (do_assign)
  187.           {
  188. --- 292,298 ----
  189.               break;
  190.           if (do_assign)
  191.               *str++ = c;
  192. !         } while ((inchar() != EOF) && ((width > 0) ? --width != 0 : 1));
  193.           
  194.           if (do_assign)
  195.           {
  196. ***************
  197. *** 468,474 ****
  198. --- 473,483 ----
  199.           if (do_assign)
  200.           {
  201.           if (is_long_double)
  202. + #ifdef __M68881__
  203.               *va_arg(arg, long double *) = fp_num;
  204. + #else
  205. +             *va_arg(arg, double *) = fp_num;
  206. + #endif
  207.           else if (is_long)
  208.               *va_arg(arg, double *) = (double) fp_num;
  209.           else
  210. ===================================================================
  211. RCS file: /net/acae127/home/bammi/etc/src/master/atari/co/_addsubd.cpp,v
  212. retrieving revision 1.6
  213. diff -c -r1.6 _addsubd.cpp
  214. *** 1.6    1993/03/01 17:33:55
  215. --- _addsubd.cpp    1993/05/29 20:28:20
  216. ***************
  217. *** 10,15 ****
  218. --- 10,19 ----
  219.   |
  220.   | written by Kai-Uwe Bloem (I5110401@dbstu1.bitnet).
  221.   | Based on a 80x86 floating point packet from comp.os.minix, written by P.Housel
  222. + |
  223. + | Revision 1.3.5 michal 05-93 (ntomczak@vm.ucs.ualberta.ca)
  224. + |   + code smoothing
  225. + |
  226.   | patched by Olaf Flebbe (flebbe@tat.physik.uni-tuebingen.de)
  227.   |
  228.   | Revision 1.3.4 olaf 11-92 :
  229. ***************
  230. *** 23,30 ****
  231.   |
  232.   | Revision 1.3.3 olaf 11-92 :
  233.   |  + changed to get rid of rounding bits. a sticky register (d3) is
  234. ! |    sufficient. 
  235. ! | 
  236.   | Revision 1.3.2 olaf 10-92 :
  237.   |  + increased comparson by one again. (Dont understand, but it works)
  238.   |  + corrected negation of rounding bits and mantissa
  239. --- 27,34 ----
  240.   |
  241.   | Revision 1.3.3 olaf 11-92 :
  242.   |  + changed to get rid of rounding bits. a sticky register (d3) is
  243. ! |    sufficient.
  244. ! |
  245.   | Revision 1.3.2 olaf 10-92 :
  246.   |  + increased comparson by one again. (Dont understand, but it works)
  247.   |  + corrected negation of rounding bits and mantissa
  248. ***************
  249. *** 59,85 ****
  250.       moveml    d2-d7,sp@-    | save registers
  251.       moveml    a0@,d4-d5/d6-d7    | d4-d5 = v, d6-d7 = u
  252.   
  253.       movel    d6,d0        | d0 = u.exp
  254.       swap    d0
  255. !     movel    d6,d2        | d2.h = u.sign
  256. !     movew    d0,d2
  257.       lsrw    #4,d0
  258. -     andw    #0x07ff,d0    | kill sign bit
  259.   
  260.       movel    d4,d1        | d1 = v.exp
  261.       swap    d1
  262. !     eorw    d1,d2        | d2.l = u.sign ^ v.sign
  263.       lsrw    #4,d1
  264. -     andw    #0x07ff,d1    | kill sign bit
  265. -     andl    #0x0fffff,d6    | remove exponent from u.mantissa
  266. -     andl    #0x0fffff,d4    | remove exponent from v.mantissa
  267.   |
  268.   | Now perform testing of NaN And infinities
  269.   |
  270. !     cmpw    #0x07ff,d0
  271.       beq    0f
  272. !     cmpw    #0x07ff,d1
  273.       bne    nospec
  274.       bra    1f
  275.   |    first operand is special
  276. --- 63,90 ----
  277.       moveml    d2-d7,sp@-    | save registers
  278.       moveml    a0@,d4-d5/d6-d7    | d4-d5 = v, d6-d7 = u
  279.   
  280. +     movel    #0x0fffff,d3
  281.       movel    d6,d0        | d0 = u.exp
  282. +     andl    d3,d6        | remove exponent from u.mantissa
  283. +     movel    d0,d2        | d2.h = u.sign
  284.       swap    d0
  285. !     movew    d0,d2        | d2.l = u.sign
  286. !     bclr    #15,d0        | kill sign bit
  287.       lsrw    #4,d0
  288.   
  289.       movel    d4,d1        | d1 = v.exp
  290. +     andl    d3,d4        | remove exponent from v.mantissa
  291.       swap    d1
  292. !     eorw    d1,d2        | d2.l = u.sign ^ v.sign (in bit 15)
  293. !     bclr    #15,d1        | kill sign bit
  294.       lsrw    #4,d1
  295.   |
  296.   | Now perform testing of NaN And infinities
  297.   |
  298. !     movew    #0x7ff,d3
  299. !     cmpw    d3,d0
  300.       beq    0f
  301. !     cmpw    d3,d1
  302.       bne    nospec
  303.       bra    1f
  304.   |    first operand is special
  305. ***************
  306. *** 88,100 ****
  307.       beq    bothspec
  308.   |
  309.   |    u is special
  310. ! | 
  311.       movel    d7,d0
  312.       orl    d6,d0
  313.       bne    retnan        | arith with Nan gives always Nan
  314.   
  315.       movel    a0@(8),d0        | copy infinity
  316. !     clrl    d1
  317.       bra     return
  318.   |
  319.   |    v is special
  320. --- 93,105 ----
  321.       beq    bothspec
  322.   |
  323.   |    u is special
  324. ! |
  325.       movel    d7,d0
  326.       orl    d6,d0
  327.       bne    retnan        | arith with Nan gives always Nan
  328.   
  329.       movel    a0@(8),d0        | copy infinity
  330. !     moveq    #0,d1
  331.       bra     return
  332.   |
  333.   |    v is special
  334. ***************
  335. *** 103,109 ****
  336.       orl    d4,d0
  337.       bne    retnan
  338.       movel    a0@,d0
  339. !     clrl    d1
  340.       bra    return
  341.   |
  342.   |    u and v are both special
  343. --- 108,114 ----
  344.       orl    d4,d0
  345.       bne    retnan
  346.       movel    a0@,d0
  347. !     moveq    #0,d1
  348.       bra    return
  349.   |
  350.   |    u and v are both special
  351. ***************
  352. *** 113,156 ****
  353.       orl    d6,d0
  354.       orl    d5,d0
  355.       orl    d4,d0
  356. !     beq    bothinf
  357. !     bra    retnan    
  358.   |
  359.   | Both are infinities Test if cancellation
  360. ! | 
  361.   bothinf:
  362.       tstw    d2
  363. !     bpl    retinf    
  364.   |
  365.   | return a quiet NaN
  366.   |
  367. ! retnan:    movel    #0x7fffffff,d0
  368. !     moveql  #-1,d1
  369.       bra    return
  370.   
  371. ! retinf: movel   #0x7ff00000,d0
  372. !     clrl    d1
  373. !     tstl    d2
  374. !     bpl    return
  375. !     bchg    #31,d0
  376.   return:    moveml    sp@+,d2-d7
  377.       rts
  378. ! |    
  379.   | Ok, no inifinty or Nan involved..
  380.   |
  381. ! nospec:    tstw    d0        | check for zero exponent - no leading "1"
  382. !     beq    0f
  383. !     bset    #20,d6        | restore implied leading "1"
  384. !     bra    1f
  385. ! 0:    addw    #1,d0        | "normalize" exponent
  386.   1:
  387. -     tstw    d1        | check for zero exponent - no leading "1"
  388. -     beq    0f
  389.       bset    #20,d4        | restore implied leading "1"
  390. !     bra    1f
  391. ! 0:    addw    #1,d1        | "normalize" exponent
  392.   1:
  393. !     clrl    d3        | init sticky register
  394.       negw    d1        | d1 = u.exp - v.exp
  395.       addw    d0,d1
  396.       beq    5f        | exponents are equal - no shifting neccessary
  397. --- 118,160 ----
  398.       orl    d6,d0
  399.       orl    d5,d0
  400.       orl    d4,d0
  401. !     bne    retnan
  402.   |
  403.   | Both are infinities Test if cancellation
  404. ! |
  405.   bothinf:
  406.       tstw    d2
  407. !     bpl    retinf
  408.   |
  409.   | return a quiet NaN
  410.   |
  411. ! retnan: moveql    #-1,d1
  412. !     movel    d1,d0
  413. !     bclr    #31,d0        | 0x7fffffff -> d0
  414.       bra    return
  415.   
  416. ! retinf:    moveq    #0,d1
  417. !     movel    #0xffe00000,d0    | we will return #0xfff00000 or #0x7ff00000
  418. !     lslw    #1,d2
  419. !     roxrl   #1,d0        | shift in high bit as given by d2
  420.   return:    moveml    sp@+,d2-d7
  421.       rts
  422. ! |
  423.   | Ok, no inifinty or Nan involved..
  424.   |
  425. ! nospec:    bset    #20,d6        | restore implied leading "1"
  426. !     tstw    d0        | check for zero exponent - no leading "1"
  427. !     bne    1f
  428. !     bclr    #20,d6        | no implied leading "1", instead ...
  429. !     addw    #1,d0        | "normalize" exponent
  430.   1:
  431.       bset    #20,d4        | restore implied leading "1"
  432. !     tstw    d1        | check for zero exponent - no leading "1"
  433. !     bne    1f
  434. !     bclr    #20,d4        | no implied leading "1", instead ...
  435. !     addw    #1,d1        | "normalize" exponent
  436.   1:
  437. !     moveq    #0,d3        | init sticky register
  438.       negw    d1        | d1 = u.exp - v.exp
  439.       addw    d0,d1
  440.       beq    5f        | exponents are equal - no shifting neccessary
  441. ***************
  442. *** 170,186 ****
  443.   | most significant digit, while gaining an additional digit for
  444.   | rounding.
  445.   |
  446. !     moveql  #1,d3    
  447.   2:    addl    d7,d7
  448.       addxl    d6,d6
  449.       subw    #1,d0        | decrement exponent
  450.       subw    #1,d1        | decrement counter
  451.       dbeq    d3,2b
  452. !     clrl    d3
  453.   |
  454.   | now shift other mantissa right as fast as possible (almost).
  455.   |
  456. ! 3:    
  457.       cmpw    #16,d1        | see if fast rotate possible
  458.       blt    4f
  459.       orw    d5,d3        | set sticky word
  460. --- 174,190 ----
  461.   | most significant digit, while gaining an additional digit for
  462.   | rounding.
  463.   |
  464. !     moveql  #1,d3
  465.   2:    addl    d7,d7
  466.       addxl    d6,d6
  467.       subw    #1,d0        | decrement exponent
  468.       subw    #1,d1        | decrement counter
  469.       dbeq    d3,2b
  470. !     moveq    #0,d3
  471.   |
  472.   | now shift other mantissa right as fast as possible (almost).
  473.   |
  474. ! 3:
  475.       cmpw    #16,d1        | see if fast rotate possible
  476.       blt    4f
  477.       orw    d5,d3        | set sticky word
  478. ***************
  479. *** 193,203 ****
  480.   
  481.   0:    moveb   d5,d2        | use d2.b as scratch
  482.       andb    #1,d2        | test if 1 is shifted out
  483. !     orb    d2,d3        | and put it in sticky 
  484.       lsrl    #1,d4        | shift v.mant right the rest of the way
  485.       roxrl    #1,d5        | to line it up with u.mant
  486.   4:    dbra    d1,0b        | loop
  487. !     
  488.   5:
  489.       tstw    d2        | are the signs equal ?
  490.       bpl    6f        | yes, no negate necessary
  491. --- 197,207 ----
  492.   
  493.   0:    moveb   d5,d2        | use d2.b as scratch
  494.       andb    #1,d2        | test if 1 is shifted out
  495. !     orb    d2,d3        | and put it in sticky
  496.       lsrl    #1,d4        | shift v.mant right the rest of the way
  497.       roxrl    #1,d5        | to line it up with u.mant
  498.   4:    dbra    d1,0b        | loop
  499.   5:
  500.       tstw    d2        | are the signs equal ?
  501.       bpl    6f        | yes, no negate necessary
  502. ***************
  503. *** 205,218 ****
  504.   | negate secand mantissa. One has to check the sticky word in order
  505.   | to correct the twos complement.
  506.   |
  507. !     tstw    d3        | 
  508.       beq     9f        | No cerrection necessary
  509. !     clrl    d1
  510.       addql   #1,d5
  511.       addxl   d1,d4
  512.   9:    negl    d5
  513.       negxl    d4
  514. !         
  515.   6:
  516.       addl    d5,d7        | u.mant = u.mant + v.mant
  517.       addxl    d4,d6
  518. --- 209,222 ----
  519.   | negate secand mantissa. One has to check the sticky word in order
  520.   | to correct the twos complement.
  521.   |
  522. !     tstw    d3        |
  523.       beq     9f        | No cerrection necessary
  524. !     moveq    #0,d1
  525.       addql   #1,d5
  526.       addxl   d1,d4
  527.   9:    negl    d5
  528.       negxl    d4
  529.   6:
  530.       addl    d5,d7        | u.mant = u.mant + v.mant
  531.       addxl    d4,d6
  532. ***************
  533. *** 226,232 ****
  534.   7:
  535.       movel    d6,d4        | move result for normalization
  536.       movel    d7,d5
  537. !     clrl    d1
  538.       tstl    d3
  539.       beq     8f
  540.       moveql   #-1,d1
  541. --- 230,236 ----
  542.   7:
  543.       movel    d6,d4        | move result for normalization
  544.       movel    d7,d5
  545. !     moveq    #0,d1
  546.       tstl    d3
  547.       beq     8f
  548.       moveql   #-1,d1
  549. ***************
  550. *** 267,278 ****
  551.       lea    0xfffffa50:w,a0
  552.       movew    #0x5400,a0@(comm)    | load first argument to fp0
  553.       cmpiw    #0x8900,a0@(resp)    | check
  554. !     movel    a7@(4),a0@
  555. !     movel    a7@(8),a0@
  556.       movew    #0x5428,a0@(comm)
  557.       .long    0x0c688900, 0xfff067f8
  558. !     movel    a7@(12),a0@
  559. !     movel    a7@(16),a0@
  560.       movew    #0x7400,a0@(comm)    | result to d0/d1
  561.       .long    0x0c688900, 0xfff067f8
  562.       movel    a0@,d0
  563. --- 271,282 ----
  564.       lea    0xfffffa50:w,a0
  565.       movew    #0x5400,a0@(comm)    | load first argument to fp0
  566.       cmpiw    #0x8900,a0@(resp)    | check
  567. !     movel    sp@(4),a0@
  568. !     movel    sp@(8),a0@
  569.       movew    #0x5428,a0@(comm)
  570.       .long    0x0c688900, 0xfff067f8
  571. !     movel    sp@(12),a0@
  572. !     movel    sp@(16),a0@
  573.       movew    #0x7400,a0@(comm)    | result to d0/d1
  574.       .long    0x0c688900, 0xfff067f8
  575.       movel    a0@,d0
  576. ***************
  577. *** 284,295 ****
  578.       lea    0xfffffa50:w,a0
  579.       movew    #0x5400,a0@(comm)        | load fp0
  580.       cmpiw    #0x8900,a0@(resp)        | got it?
  581. !     movel    a7@(4),a0@            | take a hi from stack to FPU
  582. !     movel    a7@(8),a0@            | take a lo from stack to FPU
  583.       movew    #0x5422,a0@(comm)        | add second arg to fp0
  584.       .long    0x0c688900, 0xfff067f8
  585. !     movel    a7@(12),a0@            | move b hi from stack to FPU
  586. !     movel    a7@(16),a0@            | move b lo from stack to FPU
  587.       movew    #0x7400,a0@(comm)        | result to d0/d1
  588.       .long    0x0c688900, 0xfff067f8
  589.       movel    a0@,d0                | download result
  590. --- 288,299 ----
  591.       lea    0xfffffa50:w,a0
  592.       movew    #0x5400,a0@(comm)        | load fp0
  593.       cmpiw    #0x8900,a0@(resp)        | got it?
  594. !     movel    sp@(4),a0@            | take a hi from stack to FPU
  595. !     movel    sp@(8),a0@            | take a lo from stack to FPU
  596.       movew    #0x5422,a0@(comm)        | add second arg to fp0
  597.       .long    0x0c688900, 0xfff067f8
  598. !     movel    sp@(12),a0@            | move b hi from stack to FPU
  599. !     movel    sp@(16),a0@            | move b lo from stack to FPU
  600.       movew    #0x7400,a0@(comm)        | result to d0/d1
  601.       .long    0x0c688900, 0xfff067f8
  602.       movel    a0@,d0                | download result
  603. ===================================================================
  604. RCS file: /net/acae127/home/bammi/etc/src/master/atari/co/_addsubs.cpp,v
  605. retrieving revision 1.6
  606. diff -c -r1.6 _addsubs.cpp
  607. *** 1.6    1993/03/01 17:33:57
  608. --- _addsubs.cpp    1993/05/29 20:28:21
  609. ***************
  610. *** 10,15 ****
  611. --- 10,19 ----
  612.   |
  613.   | written by Kai-Uwe Bloem (I5110401@dbstu1.bitnet).
  614.   | Based on a 80x86 floating point packet from comp.os.minix, written by P.Housel
  615. + |
  616. + | Revision 1.3.5 michal 05-93 (ntomczak@vm.ucs.ualberta.ca)
  617. + |   + code smoothing
  618. + |
  619.   | patched by Olaf Flebbe (flebbe@tat.physik.uni-tuebingen.de)
  620.   |
  621.   | Revision 1.3.4 olaf 11-92 :
  622. ***************
  623. *** 61,88 ****
  624.       moveml    d2-d5,sp@-    | save registers
  625.       moveml    a0@,d4/d5    | d4 = v, d5 = u
  626.   
  627.       movel    d5,d0        | d0 = u.exp
  628. -     swap    d0
  629.       movel    d5,d2        | d2.h = u.sign
  630. !     movew    d0,d2
  631.       lsrw    #7,d0
  632. -     andw    #0xff,d0    | kill sign bit (exponent is 8 bits)
  633.   
  634.       movel    d4,d1        | d1 = v.exp
  635.       swap    d1
  636. !     eorw    d1,d2        | d2.l = u.sign ^ v.sign
  637.       lsrw    #7,d1
  638. -     andw    #0xff,d1    | kill sign bit (exponent is 8 bits)
  639. -     andl    #0x7fffff,d5    | remove exponent from mantissa
  640. -     andl    #0x7fffff,d4    | remove exponent from mantissa
  641.   |
  642.   | Now perform testing of NaN And infinities
  643.   |
  644. !     cmpb    #0xff,d0
  645.       beq    0f
  646. !     cmpb    #0xff,d1
  647. !     bne    nospec        
  648.       bra    1f
  649.   |    first operand is special
  650.   |
  651. --- 65,93 ----
  652.       moveml    d2-d5,sp@-    | save registers
  653.       moveml    a0@,d4/d5    | d4 = v, d5 = u
  654.   
  655. +     movel    #0x7fffff,d3
  656.       movel    d5,d0        | d0 = u.exp
  657.       movel    d5,d2        | d2.h = u.sign
  658. !     swap    d0
  659. !     movew    d0,d2        | d2 = u.sign
  660. !     andl    d3,d5        | remove exponent from u.mantissa
  661. !     bclr    #15,d0        | kill sign bit
  662.       lsrw    #7,d0
  663.   
  664.       movel    d4,d1        | d1 = v.exp
  665. +     andl    d3,d4        | remove exponent from v.mantissa
  666.       swap    d1
  667. !     eorw    d1,d2        | d2 = u.sign ^ v.sign (in bit 15)
  668. !     bclr    #15,d1        | kill sign bit
  669.       lsrw    #7,d1
  670.   |
  671.   | Now perform testing of NaN And infinities
  672.   |
  673. !     moveq    #-1,d3
  674. !     cmpb    d3,d0
  675.       beq    0f
  676. !     cmpb    d3,d1
  677. !     bne    nospec
  678.       bra    1f
  679.   |    first operand is special
  680.   |
  681. ***************
  682. *** 90,100 ****
  683.       beq    bothspec
  684.   |
  685.   |    u is special
  686. ! | 
  687.       tstl    d5
  688.       bne    retnan        | arith with Nan gives always Nan
  689.   
  690. !     movel    a0@(4),d0        | copy infinity
  691.       bra     return
  692.   |
  693.   |    v is special
  694. --- 95,105 ----
  695.       beq    bothspec
  696.   |
  697.   |    u is special
  698. ! |
  699.       tstl    d5
  700.       bne    retnan        | arith with Nan gives always Nan
  701.   
  702. !     movel    a0@(4),d0    | copy infinity with its sign
  703.       bra     return
  704.   |
  705.   |    v is special
  706. ***************
  707. *** 109,150 ****
  708.   bothspec:
  709.       movel    d5,d0
  710.       orl    d4,d0
  711. !     beq    bothinf
  712. !     bra    retnan    
  713.   |
  714.   | Both are infinities Test if cancellation
  715. ! | 
  716.   bothinf:
  717.       tstw    d2
  718. !     bpl    retinf    
  719.   |
  720.   | return a quiet NaN
  721.   |
  722. ! retnan:    movel    #0x7fffffff,d0
  723.       bra    return
  724.   
  725. ! retinf: movel   #0x7f800000,d0
  726. !     tstl    d2
  727. !     bpl    return
  728. !     bchg    #31,d0
  729.   return:    moveml    sp@+,d2-d5
  730.       rts
  731. ! |    
  732.   | Ok, no inifinty or Nan involved..
  733.   |
  734. ! nospec:    tstw    d0        | check for zero exponent - no leading "1"
  735. !     beq    0f
  736. !     bset    #23,d5        | restore implied leading "1"
  737. !     bra    1f
  738. ! 0:    addw    #1,d0        | "normalize" exponent
  739.   1:
  740. -     tstw    d1        | check for zero exponent - no leading "1"
  741. -     beq    0f
  742.       bset    #23,d4        | restore implied leading "1"
  743. !     bra    1f
  744. ! 0:    addw    #1,d1        | "normalize" exponent
  745.   1:
  746. !     clrl    d3        | (put initial zero rounding bits in d3)
  747.       negw    d1        | d1 = u.exp - v.exp
  748.       addw    d0,d1
  749.       beq    5f        | exponents are equal - no shifting neccessary
  750. --- 114,154 ----
  751.   bothspec:
  752.       movel    d5,d0
  753.       orl    d4,d0
  754. !     bne    retnan
  755.   |
  756.   | Both are infinities Test if cancellation
  757. ! |
  758.   bothinf:
  759.       tstw    d2
  760. !     bpl    retinf
  761.   |
  762.   | return a quiet NaN
  763.   |
  764. ! retnan: moveql    #-1,d0
  765. !     lsrl    #1,d0        | 0x7fffffff -> d0
  766.       bra    return
  767.   
  768. ! retinf: movel    #0xff000000,d0  | we will return #0xff800000 or #0x7f800000
  769. !     lslw    #1,d2
  770. !     roxrl   #1,d0        | shift in high bit as given by d2
  771.   return:    moveml    sp@+,d2-d5
  772.       rts
  773. ! |
  774.   | Ok, no inifinty or Nan involved..
  775.   |
  776. ! nospec:    bset    #23,d5        | restore implied leading "1"
  777. !     tstw    d0        | check for zero exponent - no leading "1"
  778. !     bne    1f
  779. !     bclr    #23,d5        | remove it
  780. !     addqw    #1,d0        | "normalize" exponent
  781.   1:
  782.       bset    #23,d4        | restore implied leading "1"
  783. !     tstw    d1        | check for zero exponent - no leading "1"
  784. !     bne    1f
  785. !     bclr    #23,d4        | remove it
  786. !     addqw    #1,d1        | "normalize" exponent
  787.   1:
  788. !     moveq    #0,d3        | (put initial zero rounding bits in d3)
  789.       negw    d1        | d1 = u.exp - v.exp
  790.       addw    d0,d1
  791.       beq    5f        | exponents are equal - no shifting neccessary
  792. ***************
  793. *** 163,174 ****
  794.   | most significant digit, while gaining an additional digit for
  795.   | rounding.
  796.   |
  797. !     moveql    #1,d3    
  798.   2:    addl    d5,d5
  799. !     subw    #1,d0        | decrement exponent
  800. !     subw    #1,d1        | done shifting altogether ?
  801.       dbeq    d3,2b        | loop if still can shift u.mant more
  802. !     clrl    d3
  803.   
  804.       cmpw    #16,d1        | see if fast rotate possible
  805.       blt    4f
  806. --- 167,178 ----
  807.   | most significant digit, while gaining an additional digit for
  808.   | rounding.
  809.   |
  810. !     moveql    #1,d3
  811.   2:    addl    d5,d5
  812. !     subqw    #1,d0        | decrement exponent
  813. !     subqw    #1,d1        | done shifting altogether ?
  814.       dbeq    d3,2b        | loop if still can shift u.mant more
  815. !     moveq    #0,d3
  816.   
  817.       cmpw    #16,d1        | see if fast rotate possible
  818.       blt    4f
  819. ===================================================================
  820. RCS file: /net/acae127/home/bammi/etc/src/master/atari/co/_divdf3.cpp,v
  821. retrieving revision 1.6
  822. diff -c -r1.6 _divdf3.cpp
  823. *** 1.6    1993/05/21 12:55:07
  824. --- _divdf3.cpp    1993/05/29 20:28:23
  825. ***************
  826. *** 23,34 ****
  827.   
  828.       pea    pc@(LC0)
  829.       pea    Stderr
  830. !     jbsr    _fprintf    |
  831. !     addql    #8,a7        |
  832. !                     | set _errno to ERANGE
  833. !     moveq    #ERANGE,d0
  834.       Emove    d0,Errno
  835. !     moveml    __infinitydf,d0-d1    | return signed infinity 
  836.       btst    #31,a7@(4)        | transfer sign of dividend
  837.       beq    clear            | (mjr++)
  838.       bset    #31,d0            |
  839. --- 23,34 ----
  840.   
  841.       pea    pc@(LC0)
  842.       pea    Stderr
  843. !     jbsr    _fprintf
  844. !     addql    #8,a7
  845. !     moveq    #Erange,d0        | set _errno to ERANGE
  846.       Emove    d0,Errno
  847. !     moveml    __infinitydf,d0-d1    | return signed infinity
  848.       btst    #31,a7@(4)        | transfer sign of dividend
  849.       beq    clear            | (mjr++)
  850.       bset    #31,d0            |
  851. ***************
  852. *** 44,53 ****
  853.   | written by Kai-Uwe Bloem (I5110401@dbstu1.bitnet).
  854.   | Based on a 80x86 floating point packet from comp.os.minix, written by P.Housel
  855.   |
  856.   | patched by Olaf Flebbe (flebbe@tat.physik.uni-tuebingen.de)
  857.   |
  858.   | Revision 1.2.3 olaf 4-93
  859. ! |   + Fixed sign for retinf, and retzero: it is in d2.w 
  860.   |
  861.   | Revision 1.2.2 olaf 12-92
  862.   |   + added support for NaN and Infinites
  863. --- 44,57 ----
  864.   | written by Kai-Uwe Bloem (I5110401@dbstu1.bitnet).
  865.   | Based on a 80x86 floating point packet from comp.os.minix, written by P.Housel
  866.   |
  867. + | Revision 1.2.4 michal 05-93 (ntomczak@vm.ucs.ualberta.ca)
  868. + |   + resynchro with errno codes
  869. + |   + code smoothing
  870. + |
  871.   | patched by Olaf Flebbe (flebbe@tat.physik.uni-tuebingen.de)
  872.   |
  873.   | Revision 1.2.3 olaf 4-93
  874. ! |   + Fixed sign for retinf, and retzero: it is in d2.w
  875.   |
  876.   | Revision 1.2.2 olaf 12-92
  877.   |   + added support for NaN and Infinites
  878. ***************
  879. *** 73,98 ****
  880.       moveml    d2-d7,sp@-    | save registers
  881.       moveml    a0@,d4-d5/d6-d7    | d4-d5 = u, d6-d7 = v
  882.   
  883.       movel    d4,d0        | d0 = u.exp
  884.       swap    d0
  885.       movew    d0,d2        | d2 = u.sign
  886.       lsrw    #4,d0
  887. -     andw    #0x07ff,d0    | kill sign bit
  888.   
  889.       movel    d6,d1        | d1 = v.exp
  890.       swap    d1
  891.       eorw    d1,d2        | d2 = u.sign ^ v.sign (in bit 15)
  892.       lsrw    #4,d1
  893. -     andw    #0x07ff,d1    | kill sign bit
  894. -     andl    #0x0fffff,d4    | remove exponent from u.mantissa
  895. -     andl    #0x0fffff,d6    | remove exponent from v.mantissa
  896.   |
  897.   |
  898.   |
  899. !     cmpw    #0x7ff,d0
  900.       beq    0f        |u == NaN || u== Inf
  901. !     cmpw    #0x7ff,d1
  902.       beq    1f        | v == NaN || v == Inf
  903.       tstw    d0
  904.       bne    3f        | u not zero nor denorm
  905. --- 77,103 ----
  906.       moveml    d2-d7,sp@-    | save registers
  907.       moveml    a0@,d4-d5/d6-d7    | d4-d5 = u, d6-d7 = v
  908.   
  909. +     movel    #0x0fffff,d3
  910.       movel    d4,d0        | d0 = u.exp
  911. +     andl    d3,d4        | remove exponent from u.mantissa
  912.       swap    d0
  913.       movew    d0,d2        | d2 = u.sign
  914. +     bclr    #15,d0        | kill sign bit
  915.       lsrw    #4,d0
  916.   
  917.       movel    d6,d1        | d1 = v.exp
  918. +     andl    d3,d6        | remove exponent from v.mantissa
  919.       swap    d1
  920.       eorw    d1,d2        | d2 = u.sign ^ v.sign (in bit 15)
  921. +     bclr    #15,d1        | kill sign bit
  922.       lsrw    #4,d1
  923.   |
  924.   |
  925.   |
  926. !     movew    #0x7ff,d3
  927. !     cmpw    d3,d0
  928.       beq    0f        |u == NaN || u== Inf
  929. !     cmpw    d3,d1
  930.       beq    1f        | v == NaN || v == Inf
  931.       tstw    d0
  932.       bne    3f        | u not zero nor denorm
  933. ***************
  934. *** 107,117 ****
  935.       orl    d6,d3
  936.       bne    nospec
  937.       bra    retinf        | x/0 -> +/- Inf
  938. !     
  939.   0:    orl    d5,d4        | u == NaN ?
  940.       bne    retnan        | NaN/ x
  941. !     cmpw    #0x7ff,d1    
  942. !     beq    retnan        | Inf/Inf or Inf/NaN 
  943.       bra    retinf        | Inf/x | x != Inf && x != NaN
  944.   
  945.   1:    orl    d7,d6
  946. --- 112,122 ----
  947.       orl    d6,d3
  948.       bne    nospec
  949.       bra    retinf        | x/0 -> +/- Inf
  950.   0:    orl    d5,d4        | u == NaN ?
  951.       bne    retnan        | NaN/ x
  952. !     cmpw    #0x7ff,d1
  953. !     beq    retnan        | Inf/Inf or Inf/NaN
  954.       bra    retinf        | Inf/x | x != Inf && x != NaN
  955.   
  956.   1:    orl    d7,d6
  957. ***************
  958. *** 121,168 ****
  959.   2:    tstw    d1
  960.       bne    retzero        | 0/x ->+/- 0
  961.       orl    d5,d4
  962. !     bne    retzero        | 0/x 
  963.       bra    retnan        | 0/0
  964.   |
  965.   |    Return Infinity with correct sign
  966. ! |    
  967. ! retinf:    clrl    d1
  968. !     tstw    d2
  969. !     bpl    0f
  970. !     movel    #0xfff00000,d0
  971.   return:    moveml    sp@+,d2-d7
  972.       rts
  973. - 0:    movel    #0x7ff00000,d0
  974. -     bra    return    
  975.   |
  976.   |    Return NaN
  977.   |
  978. ! retnan: movel    #0x7fffffff,d0
  979. !     moveql    #-1,d1
  980.       bra    return
  981.   |
  982.   |    Return correct signed zero
  983.   |
  984. ! retzero:clrl    d0        | zero destination
  985. !     clrl    d1
  986. !     tstw    d2
  987. !     bge    return
  988. !     bset    #31,d0
  989.       bra    return
  990.   |
  991.   |    End of special handling
  992. ! |    
  993. ! nospec:    tstw    d0        | check for zero exponent - no leading "1"
  994. !     beq    0f
  995. !     bset    #20,d4        | restore implied leading "1"
  996. !     bra    1f
  997. ! 0:    addw    #1,d0        | "normalize" exponent
  998. ! 1:    tstw    d1        | check for zero exponent - no leading "1"
  999. !     beq    0f
  1000. !     bset    #20,d6        | restore implied leading "1"
  1001. !     bra    1f
  1002.   0:    addw    #1,d1        | "normalize" exponent
  1003.   
  1004.   1:    movew    d2,a0        | save sign
  1005. --- 126,170 ----
  1006.   2:    tstw    d1
  1007.       bne    retzero        | 0/x ->+/- 0
  1008.       orl    d5,d4
  1009. !     bne    retzero        | 0/x
  1010.       bra    retnan        | 0/0
  1011.   |
  1012.   |    Return Infinity with correct sign
  1013. ! |
  1014. ! retinf:    moveq    #0,d1
  1015. !     movel    #0xffe00000,d0
  1016. !     lslw    #1,d2
  1017. !     roxrl   #1,d0        | shift in high bit as given by d2
  1018.   return:    moveml    sp@+,d2-d7
  1019.       rts
  1020.   |
  1021.   |    Return NaN
  1022.   |
  1023. ! retnan: moveql    #-1,d1
  1024. !     movel    d1,d0
  1025. !     bclr    #31,d0        | 0x7fffffff -> d0
  1026.       bra    return
  1027.   |
  1028.   |    Return correct signed zero
  1029.   |
  1030. ! retzero:moveq    #0,d0        | zero destination
  1031. !     movel    d0,d1
  1032. !     lslw    #1,d2        | we need an extension bit
  1033. !     roxrl    #1,d0
  1034.       bra    return
  1035.   |
  1036.   |    End of special handling
  1037. ! |
  1038. ! nospec:    bset    #20,d4        | restore implied leading "1"
  1039. !     tstw    d0        | check for zero exponent - no leading "1"
  1040. !     bne    1f
  1041. !     bclr    #20,d4        | remove it
  1042. !     addw    #1,d0        | "normalize" exponent
  1043. ! 1:    bset    #20,d6        | restore implied leading "1"
  1044. !     tstw    d1        | check for zero exponent - no leading "1"
  1045. !     bne    1f
  1046. !     bclr    #20,d6        | remove it
  1047.   0:    addw    #1,d1        | "normalize" exponent
  1048.   
  1049.   1:    movew    d2,a0        | save sign
  1050. ***************
  1051. *** 172,179 ****
  1052.       addw    #66,d0        |  add loop offset, +2 for extra rounding bits
  1053.                   |   for denormalized numbers (2 implied by dbra)
  1054.       movew    #24,d1        | bit number for "implied" pos (+4 for rounding)
  1055. !     movel    #-1,d2        | zero the quotient
  1056. !     movel    #-1,d3        |  (for speed it is a one''s complement)
  1057.       subl    d7,d5        | initial subtraction,
  1058.       subxl    d6,d4        | u = u - v
  1059.   2:
  1060. --- 174,181 ----
  1061.       addw    #66,d0        |  add loop offset, +2 for extra rounding bits
  1062.                   |   for denormalized numbers (2 implied by dbra)
  1063.       movew    #24,d1        | bit number for "implied" pos (+4 for rounding)
  1064. !     moveq    #-1,d2        | zero the quotient
  1065. !     moveq    #-1,d3        |  (for speed it is a one''s complement)
  1066.       subl    d7,d5        | initial subtraction,
  1067.       subxl    d6,d4        | u = u - v
  1068.   2:
  1069. ***************
  1070. *** 196,208 ****
  1071.       addl    d7,d5        | add (restore)
  1072.       addxl    d6,d4        | u = u + v
  1073.       dbra    d0,2b        | give up if result is denormalized
  1074. ! 5:    subw    #2,d0        | remove rounding offset for denormalized nums
  1075.       notl    d2        | invert quotient to get it right
  1076.       notl    d3
  1077.   
  1078.       movel   d5,d1
  1079.       orl     d4,d1           | check for exact result
  1080. !     beq     1f              
  1081.       moveql  #-1,d1          | Set rounding bits for tie case
  1082.   1:    movel    d2,d4        | save quotient mantissa
  1083.       movel    d3,d5
  1084. --- 198,210 ----
  1085.       addl    d7,d5        | add (restore)
  1086.       addxl    d6,d4        | u = u + v
  1087.       dbra    d0,2b        | give up if result is denormalized
  1088. ! 5:    subqw    #2,d0        | remove rounding offset for denormalized nums
  1089.       notl    d2        | invert quotient to get it right
  1090.       notl    d3
  1091.   
  1092.       movel   d5,d1
  1093.       orl     d4,d1           | check for exact result
  1094. !     beq     1f
  1095.       moveql  #-1,d1          | Set rounding bits for tie case
  1096.   1:    movel    d2,d4        | save quotient mantissa
  1097.       movel    d3,d5
  1098. ===================================================================
  1099. RCS file: /net/acae127/home/bammi/etc/src/master/atari/co/_divmods.s,v
  1100. retrieving revision 1.3
  1101. diff -c -r1.3 _divmods.s
  1102. *** 1.3    1992/11/24 04:14:46
  1103. --- _divmods.s    1993/05/29 20:28:24
  1104. ***************
  1105. *** 62,68 ****
  1106.       cmpl    d2,d0        | compare with divisor
  1107.       bcs    0f
  1108.       subl    d2,d0        | big enough, subtract
  1109. !     addw    #1,d1        | and note bit into result
  1110.   0:
  1111.       dbra    d3,3b
  1112.       exg    d0,d1        | put quotient and remainder in their registers
  1113. --- 62,68 ----
  1114.       cmpl    d2,d0        | compare with divisor
  1115.       bcs    0f
  1116.       subl    d2,d0        | big enough, subtract
  1117. !     addqw    #1,d1        | and note bit into result
  1118.   0:
  1119.       dbra    d3,3b
  1120.       exg    d0,d1        | put quotient and remainder in their registers
  1121. ===================================================================
  1122. RCS file: /net/acae127/home/bammi/etc/src/master/atari/co/_divsf3.cpp,v
  1123. retrieving revision 1.6
  1124. diff -c -r1.6 _divsf3.cpp
  1125. *** 1.6    1993/05/21 12:55:08
  1126. --- _divsf3.cpp    1993/05/29 20:28:26
  1127. ***************
  1128. *** 18,38 ****
  1129.   ___divsf3:
  1130.   
  1131.   #ifdef    ERROR_CHECK
  1132. !     tstl    a7@(8)            | check if divisor is 0
  1133.       bne    no_exception
  1134.   
  1135.       pea    pc@(LC0)
  1136.       pea    Stderr
  1137. !     jbsr    _fprintf    |
  1138. !     addql    #8,a7        |
  1139. !                     | set _errno to ERANGE
  1140. !     moveq    #ERANGE,d0
  1141.       Emove    d0,Errno
  1142. !     movel    __infinitysf,d0        | return signed infinity 
  1143. !     btst    #31,a7@(4)        | transfer sign of dividend
  1144.       beq    clear            | (mjr++)
  1145.       bset    #31,d0            |
  1146. -     rts                |
  1147.   clear:                    |
  1148.       rts
  1149.   
  1150. --- 18,37 ----
  1151.   ___divsf3:
  1152.   
  1153.   #ifdef    ERROR_CHECK
  1154. !     tstl    sp@(8)            | check if divisor is 0
  1155.       bne    no_exception
  1156.   
  1157.       pea    pc@(LC0)
  1158.       pea    Stderr
  1159. !     jbsr    _fprintf
  1160. !     addql    #8,sp
  1161. !     moveq    #Erange,d0        | set _errno to ERANGE
  1162.       Emove    d0,Errno
  1163. !     movel    __infinitysf,d0        | return signed infinity
  1164. !     btst    #31,sp@(4)        | transfer sign of dividend
  1165.       beq    clear            | (mjr++)
  1166.       bset    #31,d0            |
  1167.   clear:                    |
  1168.       rts
  1169.   
  1170. ***************
  1171. *** 43,48 ****
  1172. --- 42,53 ----
  1173.   |
  1174.   | written by Kai-Uwe Bloem (I5110401@dbstu1.bitnet).
  1175.   | Based on a 80x86 floating point packet from comp.os.minix, written by P.Housel
  1176. + | Revision 1.2.4 michal 05-93 (ntomczak@vm.ucs.ualberta.ca)
  1177. + |   + resynchro with errno codes
  1178. + |   + code smoothing
  1179. + |   + removed extra code 'retz:' and 'divz:'; these cases are
  1180. + |     going back through 'retzero:' and 'retinf:'
  1181. + |
  1182.   | patched by Olaf Flebbe (flebbe@tat.physik.uni-tuebingen.de)
  1183.   |
  1184.   | Revision 1.2.3 olaf 5-93
  1185. ***************
  1186. *** 72,103 ****
  1187.       moveml    d2-d5,sp@-    | save registers
  1188.       moveml    a0@,d4/d5    | d4 = u, d5 = v
  1189.   
  1190.       movel    d4,d0        | d0 = u.exp
  1191.       swap    d0
  1192.       movew    d0,d2        | d2 = u.sign
  1193.       lsrw    #7,d0
  1194. -     andw    #0xff,d0    | kill sign bit
  1195.   
  1196.       movel    d5,d1        | d1 = v.exp
  1197.       swap    d1
  1198.       eorw    d1,d2        | d2 = u.sign ^ v.sign (in bit 15)
  1199.       lsrw    #7,d1
  1200. -     andw    #0xff,d1    | kill sign bit
  1201. -     andl    #0x7fffff,d4    | remove exponent from u.mantissa
  1202. -     andl    #0x7fffff,d5    | remove exponent from v.mantissa
  1203.   |
  1204.   |
  1205.   |
  1206. !     cmpb    #0xff,d0    
  1207.       beq    0f        |u == NaN || u== Inf
  1208. !     cmpb    #0xff,d1
  1209.       beq    1f        | v == NaN || v == Inf
  1210.       tstb    d0
  1211.       bne    3f        | u not zero nor denorm
  1212.       tstl    d4
  1213.       beq    2f        | 0/ ?
  1214. !     
  1215.   3:    tstw    d1
  1216.       bne    nospec
  1217.   
  1218. --- 77,109 ----
  1219.       moveml    d2-d5,sp@-    | save registers
  1220.       moveml    a0@,d4/d5    | d4 = u, d5 = v
  1221.   
  1222. +     movel    #0x7fffff,d3
  1223.       movel    d4,d0        | d0 = u.exp
  1224. +     andl    d3,d4        | remove exponent from u.mantissa
  1225.       swap    d0
  1226.       movew    d0,d2        | d2 = u.sign
  1227. +     bclr    #15,d0        | kill sign bit
  1228.       lsrw    #7,d0
  1229.   
  1230.       movel    d5,d1        | d1 = v.exp
  1231. +     andl    d3,d5        | remove exponent from v.mantissa
  1232.       swap    d1
  1233.       eorw    d1,d2        | d2 = u.sign ^ v.sign (in bit 15)
  1234. +     bclr    #15,d1        | kill sign bit
  1235.       lsrw    #7,d1
  1236.   |
  1237.   |
  1238.   |
  1239. !     moveq    #-1,d3
  1240. !     cmpb    d3,d0        | comparison with #0xff
  1241.       beq    0f        |u == NaN || u== Inf
  1242. !     cmpb    d3,d1
  1243.       beq    1f        | v == NaN || v == Inf
  1244.       tstb    d0
  1245.       bne    3f        | u not zero nor denorm
  1246.       tstl    d4
  1247.       beq    2f        | 0/ ?
  1248.   3:    tstw    d1
  1249.       bne    nospec
  1250.   
  1251. ***************
  1252. *** 107,114 ****
  1253.   
  1254.   0:    tstl    d4        | u == NaN ?
  1255.       bne    retnan        | NaN/ x
  1256. !     cmpb    #0xff,d1    
  1257. !     beq    retnan        | Inf/Inf or Inf/NaN 
  1258.       bra    retinf        | Inf/x | x != Inf && x != NaN
  1259.   
  1260.   1:    tstl    d5
  1261. --- 113,120 ----
  1262.   
  1263.   0:    tstl    d4        | u == NaN ?
  1264.       bne    retnan        | NaN/ x
  1265. !     cmpb    d3,d1
  1266. !     beq    retnan        | Inf/Inf or Inf/NaN
  1267.       bra    retinf        | Inf/x | x != Inf && x != NaN
  1268.   
  1269.   1:    tstl    d5
  1270. ***************
  1271. *** 118,177 ****
  1272.   2:    tstw    d1
  1273.       bne    retzero        | 0/x ->+/- 0
  1274.       tstl    d4
  1275. !     bne    retzero        | 0/x 
  1276.       bra    retnan        | 0/0
  1277.   |
  1278.   |    Return Infinity with correct sign
  1279. ! |    
  1280. ! retinf:    tstw    d2
  1281. !     bpl    0f
  1282. !     movel    #0xff800000,d0
  1283.   return:    moveml    sp@+,d2-d5
  1284.       rts
  1285. - 0:    movel    #0x7f800000,d0
  1286. -     bra    return    
  1287.   |
  1288.   |    Return NaN
  1289.   |
  1290. ! retnan: movel    #0x7fffffff,d0
  1291.       bra    return
  1292.   |
  1293.   |    Return correct signed zero
  1294.   |
  1295. ! retzero:clrl    d0        | zero destination
  1296. !     tstw    d2
  1297. !     bge    return
  1298. !     bset    #31,d0
  1299.       bra    return
  1300.   |
  1301.   |    End of special handling
  1302. ! |    
  1303. ! nospec:    tstw    d0        | check for zero exponent - no leading "1"
  1304. !     beq    0f
  1305. !     bset    #23,d4        | restore implied leading "1"
  1306. !     bra    1f
  1307. ! 0:    addw    #1,d0        | "normalize" exponent
  1308.   1:
  1309. - # ifndef ERROR_CHECK
  1310.       tstl    d4
  1311. !     beq    retz        | dividing zero
  1312. ! # endif    ERROR_CHECK
  1313.   
  1314. -     tstw    d1        | check for zero exponent - no leading "1"
  1315. -     beq    0f
  1316.       bset    #23,d5        | restore implied leading "1"
  1317. !     bra    1f
  1318. ! 0:    addw    #1,d1        | "normalize" exponent
  1319. ! 1:    tstl    d5
  1320. !     beq    divz        | divide by zero
  1321.   
  1322.       subw    d1,d0        | subtract exponents,
  1323.       addw    #BIAS4-8+1,d0    |  add bias back in, account for shift
  1324.       addw    #34,d0        |  add loop offset, +2 for extra rounding bits
  1325.                   |   for denormalized numbers (2 implied by dbra)
  1326.       movew    #27,d1        | bit number for "implied" pos (+4 for rounding)
  1327. !     movel    #-1,d3        |  zero quotient (for speed a one''s complement)
  1328.       subl    d5,d4        | initial subtraction, u = u - v
  1329.   2:
  1330.       btst    d1,d3        | divide until 1 in implied position
  1331. --- 124,181 ----
  1332.   2:    tstw    d1
  1333.       bne    retzero        | 0/x ->+/- 0
  1334.       tstl    d4
  1335. !     bne    retzero        | 0/x
  1336.       bra    retnan        | 0/0
  1337.   |
  1338.   |    Return Infinity with correct sign
  1339. ! |
  1340. ! retinf:    movel    #0xff000000,d0
  1341. !     lslw    #1,d2
  1342. !     roxrl   #1,d0        | shift in high bit as given by d2
  1343.   return:    moveml    sp@+,d2-d5
  1344.       rts
  1345.   |
  1346.   |    Return NaN
  1347.   |
  1348. ! retnan: movel    d3,d0        | d3 contains 0xffffffff
  1349. !     bclr    #31,d0
  1350.       bra    return
  1351.   |
  1352.   |    Return correct signed zero
  1353.   |
  1354. ! retzero:moveq    #0,d0        | zero destination
  1355. !     lslw    #1,d2        | set X bit accordingly
  1356. !     roxrl    #1,d0
  1357.       bra    return
  1358.   |
  1359.   |    End of special handling
  1360. ! |
  1361. ! nospec:    bset    #23,d4        | restore implied leading "1"
  1362. !     tstw    d0        | check for zero exponent - no leading "1"
  1363. !     bne    1f
  1364. !     bclr    #23,d4        | remove it
  1365. !     addw    #1,d0        | "normalize" exponent
  1366.   1:
  1367.       tstl    d4
  1368. !     beq    retzero        | dividing zero
  1369.   
  1370.       bset    #23,d5        | restore implied leading "1"
  1371. !     tstw    d1        | check for zero exponent - no leading "1"
  1372. !     bne    1f
  1373. !     bclr    #23,d5        | remove it
  1374. !     addw    #1,d1        | "normalize" exponent
  1375. ! 1:
  1376. ! # ifndef ERROR_CHECK
  1377. !     tstl    d5
  1378. !     beq    retinf        | divide by zero
  1379. ! # endif    ERROR_CHECK
  1380.   
  1381.       subw    d1,d0        | subtract exponents,
  1382.       addw    #BIAS4-8+1,d0    |  add bias back in, account for shift
  1383.       addw    #34,d0        |  add loop offset, +2 for extra rounding bits
  1384.                   |   for denormalized numbers (2 implied by dbra)
  1385.       movew    #27,d1        | bit number for "implied" pos (+4 for rounding)
  1386. !     moveql    #-1,d3        |  zero quotient (for speed a one''s complement)
  1387.       subl    d5,d4        | initial subtraction, u = u - v
  1388.   2:
  1389.       btst    d1,d3        | divide until 1 in implied position
  1390. ***************
  1391. *** 188,194 ****
  1392.       addxl    d3,d3        | shift quotient and clear bit zero
  1393.       addl    d5,d4        | add (restore), u = u + v
  1394.       dbra    d0,2b        | give up if result is denormalized
  1395. ! 5:    subw    #2,d0        | remove rounding offset for denormalized nums
  1396.       notl    d3        | invert quotient to get it right
  1397.   
  1398.       clrl    d1        | zero rounding bits
  1399. --- 192,198 ----
  1400.       addxl    d3,d3        | shift quotient and clear bit zero
  1401.       addl    d5,d4        | add (restore), u = u + v
  1402.       dbra    d0,2b        | give up if result is denormalized
  1403. ! 5:    subqw    #2,d0        | remove rounding offset for denormalized nums
  1404.       notl    d3        | invert quotient to get it right
  1405.   
  1406.       clrl    d1        | zero rounding bits
  1407. ***************
  1408. *** 198,205 ****
  1409.   1:    movel    d3,d4        | save quotient mantissa
  1410.       jmp    norm_sf        | (registers on stack removed by norm_sf)
  1411.   
  1412.   # ifndef ERROR_CHECK
  1413. ! retz:    clrl    d0        | zero destination
  1414.       moveml    sp@+,d2-d5
  1415.       rts            | no normalization needed
  1416.   
  1417. --- 202,211 ----
  1418.   1:    movel    d3,d4        | save quotient mantissa
  1419.       jmp    norm_sf        | (registers on stack removed by norm_sf)
  1420.   
  1421. + #if 0
  1422. + | this  is dead code right now - retzero and retinf used (mj)
  1423.   # ifndef ERROR_CHECK
  1424. ! retz:    moveq    #0,d0        | zero destination
  1425.       moveml    sp@+,d2-d5
  1426.       rts            | no normalization needed
  1427.   
  1428. ***************
  1429. *** 213,222 ****
  1430.       bclr    #31,d0        |
  1431.       rts
  1432.   # endif    ERROR_CHECK
  1433.   #else
  1434.   
  1435.   | single precision floating point stuff for Atari-gcc using the SFP004
  1436. ! | or compatible boards with a memory mapped 68881 
  1437.   | developed with gas
  1438.   |
  1439.   |  single floating point divide routine
  1440. --- 219,230 ----
  1441.       bclr    #31,d0        |
  1442.       rts
  1443.   # endif    ERROR_CHECK
  1444. + #endif
  1445.   #else
  1446.   
  1447.   | single precision floating point stuff for Atari-gcc using the SFP004
  1448. ! | or compatible boards with a memory mapped 68881
  1449.   | developed with gas
  1450.   |
  1451.   |  single floating point divide routine
  1452. ***************
  1453. *** 247,256 ****
  1454.       lea    0xfffffa50:w,a0
  1455.       movew    #0x4400,a0@(comm)    | load first argument to fp0
  1456.       cmpiw    #0x8900,a0@(resp)    | check
  1457. !     movel    a7@(4),a0@
  1458.       movew    #0x4424,a0@(comm)
  1459.       .long    0x0c688900, 0xfff067f8
  1460. !     movel    a7@(8),a0@
  1461.       movew    #0x6400,a0@(comm)    | result to d0
  1462.       .long    0x0c688900, 0xfff067f8
  1463.       movel    a0@,d0            | REMARK: 0/0 returns a NAN
  1464. --- 255,264 ----
  1465.       lea    0xfffffa50:w,a0
  1466.       movew    #0x4400,a0@(comm)    | load first argument to fp0
  1467.       cmpiw    #0x8900,a0@(resp)    | check
  1468. !     movel    sp@(4),a0@
  1469.       movew    #0x4424,a0@(comm)
  1470.       .long    0x0c688900, 0xfff067f8
  1471. !     movel    sp@(8),a0@
  1472.       movew    #0x6400,a0@(comm)    | result to d0
  1473.       .long    0x0c688900, 0xfff067f8
  1474.       movel    a0@,d0            | REMARK: 0/0 returns a NAN
  1475. ===================================================================
  1476. RCS file: /net/acae127/home/bammi/etc/src/master/atari/co/_extends.cpp,v
  1477. retrieving revision 1.4
  1478. diff -c -r1.4 _extends.cpp
  1479. *** 1.4    1993/03/01 17:34:03
  1480. --- _extends.cpp    1993/05/29 20:28:27
  1481. ***************
  1482. *** 14,19 ****
  1483. --- 14,22 ----
  1484.   | written by Kai-Uwe Bloem (I5110401@dbstu1.bitnet).
  1485.   | Based on a 80x86 floating point packet from comp.os.minix, written by P.Housel
  1486.   |
  1487. + | Revision 1.3, michal 05-93 :
  1488. + | code cleanup
  1489. + |
  1490.   | Revision 1.2, kub 01-90 :
  1491.   | added support for denormalized numbers
  1492.   |
  1493. ***************
  1494. *** 26,64 ****
  1495.   BIAS4    =    0x7F-1
  1496.   BIAS8    =    0x3FF-1
  1497.   
  1498. !     lea    sp@(4),a0    | parameter pointer
  1499.       moveml    d2-d7,sp@-    | save regs to keep norm_df happy
  1500. !     movel    a0@,d4        | get number
  1501. !     clrl    d5        | prepare double mantissa
  1502.   
  1503. !     movew    a0@,d0        | extract exponent
  1504.       movew    d0,d2        | extract sign
  1505.       lsrw    #7,d0
  1506. -     andw    #0xff,d0    | kill sign bit (exponent is 8 bits)
  1507.       andl    #0x7fffff,d4    | remove exponent from mantissa
  1508.   
  1509. !     cmpb    #0xff,d0
  1510.       bne    nospec
  1511.       tstl    d4
  1512.       beq    retinf
  1513.   | ret nan
  1514. !     movel    #0x7fffffff,d0
  1515. !     moveql    #-1,d1
  1516.   return:    moveml    sp@+,d2-d7
  1517.       rts
  1518. - retinf:    clrl    d1
  1519. -     movel    #0x7ff00000,d0
  1520. -     tstw    d2
  1521. -     bpl    return
  1522. -     bset    #31,d0
  1523. -     bra    return
  1524.   
  1525. !     
  1526. ! nospec:    tstw    d0        | check for zero exponent - no leading "1"
  1527. !     beq    0f        | for denormalized numbers
  1528. !     bset    #23,d4        | restore implied leading "1"
  1529. !     bra    1f
  1530. ! 0:    addw    #1,d0        | "normalize" exponent
  1531.   1:
  1532.       addw    #BIAS8-BIAS4-3,d0    | adjust bias, account for shift
  1533.       clrw    d1        | dummy rounding info
  1534. --- 29,66 ----
  1535.   BIAS4    =    0x7F-1
  1536.   BIAS8    =    0x3FF-1
  1537.   
  1538. !     movel   sp@(4),d0    | get number
  1539.       moveml    d2-d7,sp@-    | save regs to keep norm_df happy
  1540. !     moveq    #0,d5        | prepare double mantissa
  1541.   
  1542. !     movel    d0,d4
  1543. !     swap    d0        | extract exponent
  1544.       movew    d0,d2        | extract sign
  1545. +     bclr    #15,d0        | kill sign bit (exponent is 8 bits)
  1546.       lsrw    #7,d0
  1547.       andl    #0x7fffff,d4    | remove exponent from mantissa
  1548.   
  1549. !     moveql    #-1,d1
  1550. !     cmpb    d1,d0
  1551.       bne    nospec
  1552.       tstl    d4
  1553.       beq    retinf
  1554.   | ret nan
  1555. !     movel    d1,d0
  1556. !     lsrl    #1,d0        | #0x7fffffff -> d0
  1557. !     bra    return
  1558. ! retinf:    movel    d4,d1        | 0 -> d1
  1559. !     movel    #0xffe00000,d0
  1560. !     lslw    #1,d2        | get extension bit
  1561. !     roxrl    #1,d0        | shift in sign bit
  1562.   return:    moveml    sp@+,d2-d7
  1563.       rts
  1564.   
  1565. ! nospec: bset    #23,d4        | restore implied leading "1"
  1566. !     tstw    d0        | check for zero exponent - no leading "1"
  1567. !     bne    1f        | for denormalized numbers
  1568. !     bclr    #23,d4        | so clear it and ...
  1569. !     addw    #1,d0        | "normalize" exponent
  1570.   1:
  1571.       addw    #BIAS8-BIAS4-3,d0    | adjust bias, account for shift
  1572.       clrw    d1        | dummy rounding info
  1573. ***************
  1574. *** 97,103 ****
  1575.       lea    0xfffffa50:w,a0
  1576.       movew    #0x4400,a0@(comm)    | load argument to fp0
  1577.       cmpiw    #0x8900,a0@(resp)    | check
  1578. !     movel    a7@(4),a0@        | now push arg
  1579.       movew    #0x7400,a0@(comm)    | result to d0/d1
  1580.       .long    0x0c688900, 0xfff067f8
  1581.       movel    a0@,d0            | pop double float
  1582. --- 99,105 ----
  1583.       lea    0xfffffa50:w,a0
  1584.       movew    #0x4400,a0@(comm)    | load argument to fp0
  1585.       cmpiw    #0x8900,a0@(resp)    | check
  1586. !     movel    sp@(4),a0@        | now push arg
  1587.       movew    #0x7400,a0@(comm)    | result to d0/d1
  1588.       .long    0x0c688900, 0xfff067f8
  1589.       movel    a0@,d0            | pop double float
  1590. ***************
  1591. *** 122,130 ****
  1592.   | no NAN checking implemented since the 68881 treats this situation "correct",
  1593.   | i.e. according to IEEE
  1594.   
  1595. !     fmoves    a7@(4),fp0    | load argument to fp0
  1596. !     fmoved    fp0,a7@-    | read back as double
  1597. !     moveml    a7@+,d0-d1
  1598.       rts
  1599.   
  1600.   #endif    __M68881__
  1601. --- 124,132 ----
  1602.   | no NAN checking implemented since the 68881 treats this situation "correct",
  1603.   | i.e. according to IEEE
  1604.   
  1605. !     fmoves    sp@(4),fp0    | load argument to fp0
  1606. !     fmoved    fp0,sp@-    | read back as double
  1607. !     moveml    sp@+,d0-d1
  1608.       rts
  1609.   
  1610.   #endif    __M68881__
  1611. ===================================================================
  1612. RCS file: /net/acae127/home/bammi/etc/src/master/atari/co/_fixdfsi.cpp,v
  1613. retrieving revision 1.4
  1614. diff -c -r1.4 _fixdfsi.cpp
  1615. *** 1.4    1993/03/01 17:34:05
  1616. --- _fixdfsi.cpp    1993/05/29 20:28:28
  1617. ***************
  1618. *** 40,51 ****
  1619.       lea    0xfffffa50:w,a0
  1620.       movew    #0x5403,a0@(comm)    | fintrz to fp0
  1621.       cmpiw    #0x8900,a0@(resp)    | check
  1622. !     movel    a7@(4),a0@
  1623. !     movel    a7@(8),a0@
  1624.       movew    #0x6000,a0@(comm)    | result to d0
  1625.       .long    0x0c688900, 0xfff067f8
  1626.       movel    a0@,d0
  1627. !         
  1628.   #endif    sfp004
  1629.   #ifdef    __M68881__
  1630.   
  1631. --- 40,51 ----
  1632.       lea    0xfffffa50:w,a0
  1633.       movew    #0x5403,a0@(comm)    | fintrz to fp0
  1634.       cmpiw    #0x8900,a0@(resp)    | check
  1635. !     movel    sp@(4),a0@
  1636. !     movel    sp@(8),a0@
  1637.       movew    #0x6000,a0@(comm)    | result to d0
  1638.       .long    0x0c688900, 0xfff067f8
  1639.       movel    a0@,d0
  1640.   #endif    sfp004
  1641.   #ifdef    __M68881__
  1642.   
  1643. ***************
  1644. *** 98,111 ****
  1645.       moveml    a0@,d0-d1    | get the number
  1646.       movew    a0@,d2        | extract exp
  1647.       movew    d2,d3        | extract sign
  1648.       lsrw    #4,d2
  1649. -     andw    #0x07ff,d2    | kill sign bit
  1650.   
  1651.       andl    #0x0fffff,d0    | remove exponent from mantissa
  1652.       bset    #20,d0        | restore implied leading "1"
  1653.   
  1654.       cmpw    #BIAS8,d2    | check exponent
  1655. !     blt    zero        | strictly factional, no integer part ?
  1656.       cmpw    #BIAS8+32,d2    | is it too big to fit in a 32-bit integer ?
  1657.       bgt    toobig
  1658.   
  1659. --- 98,111 ----
  1660.       moveml    a0@,d0-d1    | get the number
  1661.       movew    a0@,d2        | extract exp
  1662.       movew    d2,d3        | extract sign
  1663. +     bclr    #15,d2        | kill sign bit
  1664.       lsrw    #4,d2
  1665.   
  1666.       andl    #0x0fffff,d0    | remove exponent from mantissa
  1667.       bset    #20,d0        | restore implied leading "1"
  1668.   
  1669.       cmpw    #BIAS8,d2    | check exponent
  1670. !     blt    zero        | strictly fractional, no integer part ?
  1671.       cmpw    #BIAS8+32,d2    | is it too big to fit in a 32-bit integer ?
  1672.       bgt    toobig
  1673.   
  1674. ***************
  1675. *** 120,126 ****
  1676.   
  1677.   2:    addl    d1,d1        | shift up to align radix point
  1678.       addxl    d0,d0
  1679. !     subw    #1,d2
  1680.       bgt    2b
  1681.   
  1682.   3:    cmpl    #0x80000000,d0    | -2147483648 is a nasty evil special case
  1683. --- 120,126 ----
  1684.   
  1685.   2:    addl    d1,d1        | shift up to align radix point
  1686.       addxl    d0,d0
  1687. !     subqw    #1,d2
  1688.       bgt    2b
  1689.   
  1690.   3:    cmpl    #0x80000000,d0    | -2147483648 is a nasty evil special case
  1691. ***************
  1692. *** 143,149 ****
  1693.       bra    8b
  1694.   
  1695.   toobig:
  1696. !     movel    #0x7fffffff,d0    | ugh. Should cause a trap here.
  1697.       moveml    sp@+,d2/d3
  1698.   
  1699.   #endif /* !defined (sfp004) && !defined (__M68881__) */
  1700. --- 143,150 ----
  1701.       bra    8b
  1702.   
  1703.   toobig:
  1704. !     moveq    #-1,d0        | ugh. Should cause a trap here.
  1705. !     bclr    #31,d0
  1706.       moveml    sp@+,d2/d3
  1707.   
  1708.   #endif /* !defined (sfp004) && !defined (__M68881__) */
  1709. ***************
  1710. *** 157,171 ****
  1711.       ble    error_msg
  1712.       rts
  1713.   error_msg:
  1714. !     moveml    d0-d1,a7@-
  1715. !     moveq    #ERANGE,d0
  1716.       Emove    d0,Errno
  1717.       pea    pc@(_Overflow)    | for printf
  1718. !     pea    pc@(_Error_String)    |
  1719.       pea    Stderr
  1720. !     jbsr    _fprintf    |
  1721. !     addl    #12,a7        |
  1722. !     moveml    a7@+,d0-d1
  1723.   #endif    /* ERROR_CHECK */
  1724.   
  1725.       rts
  1726. --- 158,172 ----
  1727.       ble    error_msg
  1728.       rts
  1729.   error_msg:
  1730. !     moveml    d0-d1,sp@-
  1731. !     moveq    #Erange,d0
  1732.       Emove    d0,Errno
  1733.       pea    pc@(_Overflow)    | for printf
  1734. !     pea    pc@(_Error_String)
  1735.       pea    Stderr
  1736. !     jbsr    _fprintf
  1737. !     addl    #12,sp
  1738. !     moveml    sp@+,d0-d1
  1739.   #endif    /* ERROR_CHECK */
  1740.   
  1741.       rts
  1742. ===================================================================
  1743. RCS file: /net/acae127/home/bammi/etc/src/master/atari/co/_fixsfsi.cpp,v
  1744. retrieving revision 1.3
  1745. diff -c -r1.3 _fixsfsi.cpp
  1746. *** 1.3    1993/03/01 17:34:07
  1747. --- _fixsfsi.cpp    1993/05/29 20:28:30
  1748. ***************
  1749. *** 28,34 ****
  1750.   1:    cmpiw    #0x8900,a0@(resp)
  1751.       beq    1b
  1752.       movel    a0@,d0
  1753. !         
  1754.   #else /* !sfp004 */
  1755.   
  1756.   BIAS4    =    0x7F-1
  1757. --- 28,34 ----
  1758.   1:    cmpiw    #0x8900,a0@(resp)
  1759.       beq    1b
  1760.       movel    a0@,d0
  1761.   #else /* !sfp004 */
  1762.   
  1763.   BIAS4    =    0x7F-1
  1764. ***************
  1765. *** 38,45 ****
  1766.       movel    d0,d1
  1767.       swap    d1        | extract exp
  1768.       movew    d1,d2        | extract sign
  1769.       lsrw    #7,d1
  1770. -     andw    #0xff,d1    | kill sign bit
  1771.   
  1772.       andl    #0x7fffff,d0    | remove exponent from mantissa
  1773.       bset    #23,d0        | restore implied leading "1"
  1774. --- 38,45 ----
  1775.       movel    d0,d1
  1776.       swap    d1        | extract exp
  1777.       movew    d1,d2        | extract sign
  1778. +     bclr    #15,d1        | kill sign bit
  1779.       lsrw    #7,d1
  1780.   
  1781.       andl    #0x7fffff,d0    | remove exponent from mantissa
  1782.       bset    #23,d0        | restore implied leading "1"
  1783. ***************
  1784. *** 80,86 ****
  1785.       bra    8b
  1786.   
  1787.   toobig:
  1788. !     movel    #0x7fffffff,d0    | ugh. Should cause a trap here.
  1789.       bra    8b
  1790.   
  1791.   #endif /* !sfp004*/
  1792. --- 80,87 ----
  1793.       bra    8b
  1794.   
  1795.   toobig:
  1796. !     moveq    #-1,d0        | ugh. Should cause a trap here.
  1797. !     bclr    #31,d0        | make it #0x7fffffff
  1798.       bra    8b
  1799.   
  1800.   #endif /* !sfp004*/
  1801. ===================================================================
  1802. RCS file: /net/acae127/home/bammi/etc/src/master/atari/co/_fltsi.cpp,v
  1803. retrieving revision 1.3
  1804. diff -c -r1.3 _fltsi.cpp
  1805. *** 1.3    1992/10/09 20:35:29
  1806. --- _fltsi.cpp    1993/05/29 20:28:31
  1807. ***************
  1808. *** 72,86 ****
  1809.       moveml    d2-d7,sp@-    | save registers to make norm_df happy
  1810.   
  1811.       movel    d0,d4        | prepare result mantissa
  1812. !     clrl    d5
  1813.       movew    #BIAS8+32-11,d0    | radix point after 32 bits
  1814.   0:
  1815.       movel    d4,d2        | set sign flag
  1816. -     swap    d2
  1817. -     tstw    d2        | check sign of number
  1818.       bge    1f        | nonnegative
  1819.       negl    d4        | take absolute value
  1820.   1:
  1821.       clrw    d1        | set rounding = 0
  1822.       jmp    norm_df
  1823.   
  1824. --- 72,85 ----
  1825.       moveml    d2-d7,sp@-    | save registers to make norm_df happy
  1826.   
  1827.       movel    d0,d4        | prepare result mantissa
  1828. !     moveq    #0,d5
  1829.       movew    #BIAS8+32-11,d0    | radix point after 32 bits
  1830.   0:
  1831.       movel    d4,d2        | set sign flag
  1832.       bge    1f        | nonnegative
  1833.       negl    d4        | take absolute value
  1834.   1:
  1835. +     swap    d2        | follow norm_df conventions
  1836.       clrw    d1        | set rounding = 0
  1837.       jmp    norm_df
  1838.   
  1839. ===================================================================
  1840. RCS file: /net/acae127/home/bammi/etc/src/master/atari/co/_fltsisf.cpp,v
  1841. retrieving revision 1.2
  1842. diff -c -r1.2 _fltsisf.cpp
  1843. *** 1.2    1992/10/09 20:35:29
  1844. --- _fltsisf.cpp    1993/05/29 20:28:32
  1845. ***************
  1846. *** 39,49 ****
  1847.       movel    sp@(20),d4    | prepare result mantissa
  1848.       movew    #BIAS4+32-8,d0    | radix point after 32 bits
  1849.       movel    d4,d2        | set sign flag
  1850. -     swap    d2
  1851. -     tstw    d2        | check sign of number
  1852.       bge    1f        | nonnegative
  1853.       negl    d4        | take absolute value
  1854.   1:
  1855.       clrw    d1        | set rounding = 0
  1856.       jmp    norm_sf
  1857.   
  1858. --- 39,48 ----
  1859.       movel    sp@(20),d4    | prepare result mantissa
  1860.       movew    #BIAS4+32-8,d0    | radix point after 32 bits
  1861.       movel    d4,d2        | set sign flag
  1862.       bge    1f        | nonnegative
  1863.       negl    d4        | take absolute value
  1864.   1:
  1865. +     swap    d2        | follow norm_sf conventions
  1866.       clrw    d1        | set rounding = 0
  1867.       jmp    norm_sf
  1868.   
  1869. ===================================================================
  1870. RCS file: /net/acae127/home/bammi/etc/src/master/atari/co/_fxunsd.cpp,v
  1871. retrieving revision 1.3
  1872. diff -c -r1.3 _fxunsd.cpp
  1873. *** 1.3    1993/03/01 17:34:09
  1874. --- _fxunsd.cpp    1993/05/29 20:28:33
  1875. ***************
  1876. *** 21,29 ****
  1877.   ___fixunsdfsi:
  1878.   
  1879.   #ifdef ERROR_CHECK
  1880. !     tstl    a7@(4)            | negative?
  1881.       beq    Continue
  1882. !     moveq    #ERANGE,d0
  1883.       Emove    d0,Errno
  1884.       pea    pc@(_Negative)
  1885.       bra    error_exit
  1886. --- 21,29 ----
  1887.   ___fixunsdfsi:
  1888.   
  1889.   #ifdef ERROR_CHECK
  1890. !     tstl    sp@(4)            | negative?
  1891.       beq    Continue
  1892. !     moveq    #Erange,d0
  1893.       Emove    d0,Errno
  1894.       pea    pc@(_Negative)
  1895.       bra    error_exit
  1896. ***************
  1897. *** 31,37 ****
  1898.   #endif /* ERROR_CHECK */
  1899.   #ifdef __M68881__
  1900.   
  1901. !     fintrzd a7@(4),fp0        | convert
  1902.       fmovel    fp0,d0
  1903.   
  1904.   #endif __M68881__
  1905. --- 31,37 ----
  1906.   #endif /* ERROR_CHECK */
  1907.   #ifdef __M68881__
  1908.   
  1909. !     fintrzd sp@(4),fp0        | convert
  1910.       fmovel    fp0,d0
  1911.   
  1912.   #endif __M68881__
  1913. ***************
  1914. *** 48,55 ****
  1915.       lea    0xfffffa50:w,a0
  1916.       movew    #0x5403,a0@(comm)    | fintrz to fp0
  1917.       cmpiw    #0x8900,a0@(resp)    | check
  1918. !     movel    a7@(4),a0@
  1919. !     movel    a7@(8),a0@
  1920.       movew    #0x6000,a0@(comm)    | result to d0
  1921.       .long    0x0c688900, 0xfff067f8
  1922.       movel    a0@,d0
  1923. --- 48,55 ----
  1924.       lea    0xfffffa50:w,a0
  1925.       movew    #0x5403,a0@(comm)    | fintrz to fp0
  1926.       cmpiw    #0x8900,a0@(resp)    | check
  1927. !     movel    sp@(4),a0@
  1928. !     movel    sp@(8),a0@
  1929.       movew    #0x6000,a0@(comm)    | result to d0
  1930.       .long    0x0c688900, 0xfff067f8
  1931.       movel    a0@,d0
  1932. ***************
  1933. *** 81,94 ****
  1934.       moveml    d4/d5,sp@-    | save registers
  1935.       moveml    a0@,d4-d5    | get the number
  1936.       movew    a0@,d0        | extract exp
  1937.       lsrw    #4,d0
  1938. -     andw    #0x07ff,d0    | kill sign bit
  1939.   
  1940.       andl    #0x0fffff,d4    | remove exponent from mantissa
  1941.       bset    #20,d4        | restore implied leading "1"
  1942.   
  1943.       cmpw    #BIAS8,d0    | check exponent
  1944. !     blt    zero        | strictly factional, no integer part ?
  1945.       cmpw    #BIAS8+32,d0    | is it too big to fit in a 32-bit integer ?
  1946.       bgt    toobig
  1947.   
  1948. --- 81,94 ----
  1949.       moveml    d4/d5,sp@-    | save registers
  1950.       moveml    a0@,d4-d5    | get the number
  1951.       movew    a0@,d0        | extract exp
  1952. +     bclr    #15,d0        | kill sign bit
  1953.       lsrw    #4,d0
  1954.   
  1955.       andl    #0x0fffff,d4    | remove exponent from mantissa
  1956.       bset    #20,d4        | restore implied leading "1"
  1957.   
  1958.       cmpw    #BIAS8,d0    | check exponent
  1959. !     blt    zero        | strictly fractional, no integer part ?
  1960.       cmpw    #BIAS8+32,d0    | is it too big to fit in a 32-bit integer ?
  1961.       bgt    toobig
  1962.   
  1963. ***************
  1964. *** 107,119 ****
  1965.       beq    3f
  1966.   
  1967.   1:    lsrl    #1,d4        | shift down to align radix point;
  1968. !     addw    #1,d0        | extra bits fall off the end (no rounding)
  1969.       blt    1b        | shifted all the way down yet ?
  1970.       bra    3f
  1971.   
  1972.   2:    addl    d5,d5        | shift up to align radix point
  1973.       addxl    d4,d4
  1974. !     subw    #1,d0
  1975.       bgt    2b
  1976.   3:
  1977.       movel    d4,d0        | put integer into result register
  1978. --- 107,119 ----
  1979.       beq    3f
  1980.   
  1981.   1:    lsrl    #1,d4        | shift down to align radix point;
  1982. !     addqw    #1,d0        | extra bits fall off the end (no rounding)
  1983.       blt    1b        | shifted all the way down yet ?
  1984.       bra    3f
  1985.   
  1986.   2:    addl    d5,d5        | shift up to align radix point
  1987.       addxl    d4,d4
  1988. !     subqw    #1,d0
  1989.       bgt    2b
  1990.   3:
  1991.       movel    d4,d0        | put integer into result register
  1992. ***************
  1993. *** 127,133 ****
  1994.   
  1995.   toobig:
  1996.       moveml    sp@+,d4/d5
  1997. !     movel    #0x7fffffff,d0    | ugh. Should cause a trap here.
  1998.   #endif
  1999.   
  2000.   #ifdef    ERROR_CHECK
  2001. --- 127,134 ----
  2002.   
  2003.   toobig:
  2004.       moveml    sp@+,d4/d5
  2005. !     moveq    #-1,d0        | ugh. Should cause a trap here.
  2006. !     bclr    #31,d0
  2007.   #endif
  2008.   
  2009.   #ifdef    ERROR_CHECK
  2010. ***************
  2011. *** 135,150 ****
  2012.       bge    error_plus    |
  2013.       rts
  2014.   error_plus:
  2015. !     moveml    d0-d1,a7@-
  2016. !     moveq    #ERANGE,d0
  2017.       Emove    d0,Errno
  2018.       pea    pc@(_Overflow)    | for printf
  2019.   error_exit:
  2020.       pea    pc@(_Error_String)    |
  2021.       pea    Stderr
  2022.       jbsr    _fprintf    |
  2023. !     addl    #12,a7        |
  2024. !     moveml    a7@+,d0-d1
  2025.   #endif    ERROR_CHECK
  2026.       rts
  2027.   
  2028. --- 136,151 ----
  2029.       bge    error_plus    |
  2030.       rts
  2031.   error_plus:
  2032. !     moveml    d0-d1,sp@-
  2033. !     moveq    #Erange,d0
  2034.       Emove    d0,Errno
  2035.       pea    pc@(_Overflow)    | for printf
  2036.   error_exit:
  2037.       pea    pc@(_Error_String)    |
  2038.       pea    Stderr
  2039.       jbsr    _fprintf    |
  2040. !     addl    #12,sp        |
  2041. !     moveml    sp@+,d0-d1
  2042.   #endif    ERROR_CHECK
  2043.       rts
  2044.   
  2045. ===================================================================
  2046. RCS file: /net/acae127/home/bammi/etc/src/master/atari/co/_muldf3.cpp,v
  2047. retrieving revision 1.4
  2048. diff -c -r1.4 _muldf3.cpp
  2049. *** 1.4    1993/03/01 17:34:12
  2050. --- _muldf3.cpp    1993/05/29 20:28:35
  2051. ***************
  2052. *** 58,65 ****
  2053. --- 58,72 ----
  2054.   |
  2055.   | written by Kai-Uwe Bloem (I5110401@dbstu1.bitnet).
  2056.   | Based on a 80x86 floating point packet from comp.os.minix, written by P.Housel
  2057. + |
  2058. + | Revision 1.2.3 michal 05-93 (ntomczak@vm.ucs.ualberta.ca)
  2059. + |   + code smoothing
  2060. + |
  2061.   | patched by Olaf Flebbe (flebbe@tat.physik.uni-tuebingen.de)
  2062.   |
  2063. + | Revision 1.2.2 olaf 05-93:
  2064. + |   + fixed a bug for signed bug for 0.
  2065. + |
  2066.   | Revision 1.2.1 olaf 12-92:
  2067.   |   + added support for NaN and Infinites
  2068.   |   + added support for -0
  2069. ***************
  2070. *** 79,104 ****
  2071.       moveml    d2-d7,sp@-
  2072.       moveml    a0@,d4-d5/d6-d7 | d4-d5 = v, d6-d7 = u
  2073.   
  2074.       movel    d6,d0        | d0 = u.exp
  2075.       swap    d0
  2076.       movew    d0,d2        | d2 = u.sign
  2077.       lsrw    #4,d0
  2078. -     andw    #0x07ff,d0    | kill sign bit
  2079.   
  2080.       movel    d4,d1        | d1 = v.exp
  2081.       swap    d1
  2082. !     eorw    d1,d2        | d2 = u.sign ^ v.sign (in bit 31)
  2083.       lsrw    #4,d1
  2084. -     andw    #0x07ff,d1    | kill sign bit
  2085. -     andl    #0x0fffff,d6    | remove exponent from u.mantissa
  2086. -     andl    #0x0fffff,d4    | remove exponent from v.mantissa
  2087.   |
  2088.   | Testing for NaN and Infinities
  2089.   |
  2090. !     cmpw    #0x7ff,d0
  2091.       beq    0f
  2092. !     cmpw    #0x7ff,d1
  2093.       bne    nospec
  2094.       bra    1f
  2095.   |    first operand is special
  2096. --- 86,112 ----
  2097.       moveml    d2-d7,sp@-
  2098.       moveml    a0@,d4-d5/d6-d7 | d4-d5 = v, d6-d7 = u
  2099.   
  2100. +     movel    #0x0fffff,d3
  2101.       movel    d6,d0        | d0 = u.exp
  2102. +     andl    d3,d6        | remove exponent from u.mantissa
  2103.       swap    d0
  2104.       movew    d0,d2        | d2 = u.sign
  2105. +     bclr    #15,d0        | kill sign bit
  2106.       lsrw    #4,d0
  2107.   
  2108.       movel    d4,d1        | d1 = v.exp
  2109. +     andl    d3,d4        | remove exponent from v.mantissa
  2110.       swap    d1
  2111. !     eorw    d1,d2        | d2 = u.sign ^ v.sign (in bit 15)
  2112. !     bclr    #15,d1        | kill sign bit
  2113.       lsrw    #4,d1
  2114.   |
  2115.   | Testing for NaN and Infinities
  2116.   |
  2117. !     movew    #0x7ff,d3
  2118. !     cmpw    d3,d0
  2119.       beq    0f
  2120. !     cmpw    d3,d1
  2121.       bne    nospec
  2122.       bra    1f
  2123.   |    first operand is special
  2124. ***************
  2125. *** 110,129 ****
  2126.       bne    retinf  |  Inf  * x == Inf
  2127.       orl    d5,d4
  2128.       beq    retnan  | Inf * 0 == NaN
  2129. ! retinf:    
  2130. !     clrl    d1
  2131. !     tstl    d2
  2132. !     bpl    0f
  2133. !     movel    #0xfff00000,d0
  2134.   return:    moveml    sp@+,d2-d7
  2135.       rts
  2136. ! 0:    movel    #0x7ff00000,d0
  2137. !     bra    return    
  2138. ! retnan: movel    #0x7fffffff,d0
  2139. !     moveql    #-1,d1
  2140.       bra    return
  2141.   |
  2142.   | v is special
  2143. --- 118,138 ----
  2144.       bne    retinf  |  Inf  * x == Inf
  2145.       orl    d5,d4
  2146.       beq    retnan  | Inf * 0 == NaN
  2147. ! |
  2148. ! |    Return Infinity with correct sign
  2149. ! |
  2150. ! retinf:    moveq    #0,d1
  2151. !     movel    #0xffe00000,d0    | we will return #0xfff00000 or #0x7ff00000
  2152. !     lslw    #1,d2
  2153. !     roxrl   #1,d0        | shift in high bit as given by d2
  2154.   return:    moveml    sp@+,d2-d7
  2155.       rts
  2156. ! |
  2157. ! |    Return NaN
  2158. ! |
  2159. ! retnan: moveql    #-1,d1
  2160. !     movel    d1,d0
  2161. !     bclr    #31,d0        | 0x7fffffff -> d0
  2162.       bra    return
  2163.   |
  2164.   | v is special
  2165. ***************
  2166. *** 137,159 ****
  2167.       bra    retinf
  2168.   |
  2169.   | end of NaN and Inf.
  2170. ! |    
  2171.   nospec:    subw    #16,sp        | multiplication accumulator
  2172.   
  2173. -     tstw    d0        | check for zero exponent - no leading "1"
  2174. -     beq    0f
  2175.       bset    #20,d6        | restore implied leading "1"
  2176. !     bra    1f
  2177. ! 0:    addw    #1,d0        | "normalize" exponent
  2178.   1:    movel    d6,d3
  2179.       orl    d7,d3
  2180.       beq    retz        | multiplying by zero
  2181.   
  2182. -     tstw    d1        | check for zero exponent - no leading "1"
  2183. -     beq    0f
  2184.       bset    #20,d4        | restore implied leading "1"
  2185. !     bra    1f
  2186. ! 0:    addw    #1,d1        | "normalize" exponent
  2187.   1:    movel    d4,d3
  2188.       orl    d5,d3
  2189.       beq    retz        | multiplying by zero
  2190. --- 146,168 ----
  2191.       bra    retinf
  2192.   |
  2193.   | end of NaN and Inf.
  2194. ! |
  2195.   nospec:    subw    #16,sp        | multiplication accumulator
  2196.   
  2197.       bset    #20,d6        | restore implied leading "1"
  2198. !     tstw    d0        | check for zero exponent - no leading "1"
  2199. !     bne    1f
  2200. !     bclr    #20,d6        | remove it
  2201. !     addw    #1,d0        | "normalize" exponent
  2202.   1:    movel    d6,d3
  2203.       orl    d7,d3
  2204.       beq    retz        | multiplying by zero
  2205.   
  2206.       bset    #20,d4        | restore implied leading "1"
  2207. !     tstw    d1        | check for zero exponent - no leading "1"
  2208. !     bne    1f
  2209. !     bclr    #20,d4        | remove it
  2210. !     addw    #1,d1        | "normalize" exponent
  2211.   1:    movel    d4,d3
  2212.       orl    d5,d3
  2213.       beq    retz        | multiplying by zero
  2214. ***************
  2215. *** 161,171 ****
  2216.       addw    d1,d0        | add exponents,
  2217.       subw    #BIAS8+16-11,d0    | remove excess bias, acnt for repositioning
  2218.   
  2219. !     clrl    sp@        | initialize 128-bit product to zero
  2220. !     clrl    sp@(4)
  2221. !     clrl    sp@(8)
  2222. !     clrl    sp@(12)
  2223. !     lea    sp@(8),a1    | accumulator pointer
  2224.   
  2225.   | see Knuth, Seminumerical Algorithms, section 4.3. algorithm M
  2226.   
  2227. --- 170,182 ----
  2228.       addw    d1,d0        | add exponents,
  2229.       subw    #BIAS8+16-11,d0    | remove excess bias, acnt for repositioning
  2230.   
  2231. !     lea    sp@,a1        | initialize 128-bit product to zero
  2232. !     moveq    #0,d3
  2233. !     movel    d3,a1@+
  2234. !     movel    d3,a1@+
  2235. !     movel    d3,a1@+
  2236. !     movel    d3,a1@
  2237. !     subqw    #4,a1        | an address of sp@(8) in a1
  2238.   
  2239.   | see Knuth, Seminumerical Algorithms, section 4.3. algorithm M
  2240.   
  2241. ***************
  2242. *** 202,209 ****
  2243.   
  2244.       moveml    sp@(2),d4-d7    | get the 112 valid bits
  2245.       clrw    d7        | (pad to 128)
  2246.   2:
  2247. !     cmpl    #0x0000ffff,d4    | multiply (shift) until
  2248.       bhi    3f        |  1 in upper 16 result bits
  2249.       cmpw    #9,d0        | give up for denormalized numbers
  2250.       ble    3f
  2251. --- 213,221 ----
  2252.   
  2253.       moveml    sp@(2),d4-d7    | get the 112 valid bits
  2254.       clrw    d7        | (pad to 128)
  2255. +     movel    #0x0000ffff,d3
  2256.   2:
  2257. !     cmpl    d3,d4        | multiply (shift) until
  2258.       bhi    3f        |  1 in upper 16 result bits
  2259.       cmpw    #9,d0        | give up for denormalized numbers
  2260.       ble    3f
  2261. ***************
  2262. *** 227,235 ****
  2263.       orb    #1,d1        | set "sticky bit" if any low-order set
  2264.   4:    addw    #16,sp        | remove accumulator from stack
  2265.       jmp    norm_df        | (result in d4/d5)
  2266. ! retz:    clrl    d0        | save zero as result
  2267. !     clrl    d1
  2268.       addw    #16,sp
  2269.       moveml    sp@+,d2-d7
  2270.       rts            | no normalizing neccessary
  2271. --- 239,249 ----
  2272.       orb    #1,d1        | set "sticky bit" if any low-order set
  2273.   4:    addw    #16,sp        | remove accumulator from stack
  2274.       jmp    norm_df        | (result in d4/d5)
  2275. ! |                | norm_df does not return here
  2276. ! retz:    moveq    #0,d0        | save zero as result
  2277. !     movel    d0,d1
  2278. !     lslw    #1,d2        | fill X bit
  2279. !     roxrl    #1,d0        | set high bit of d0 accordingly
  2280.       addw    #16,sp
  2281.       moveml    sp@+,d2-d7
  2282.       rts            | no normalizing neccessary
  2283. ===================================================================
  2284. RCS file: /net/acae127/home/bammi/etc/src/master/atari/co/_mulsf3.cpp,v
  2285. retrieving revision 1.4
  2286. diff -c -r1.4 _mulsf3.cpp
  2287. *** 1.4    1993/03/01 17:34:14
  2288. --- _mulsf3.cpp    1993/05/29 20:28:36
  2289. ***************
  2290. *** 30,39 ****
  2291.       lea    0xfffffa50:w,a0
  2292.       movew    #0x4400,a0@(comm)    | load first argument to fp0
  2293.       cmpiw    #0x8900,a0@(resp)    | check
  2294. !     movel    a7@(4),a0@
  2295.       movew    #0x4427,a0@(comm)
  2296.       .long    0x0c688900, 0xfff067f8
  2297. !     movel    a7@(8),a0@
  2298.       movew    #0x6400,a0@(comm)    | result to d0
  2299.       .long    0x0c688900, 0xfff067f8
  2300.       movel    a0@,d0
  2301. --- 30,39 ----
  2302.       lea    0xfffffa50:w,a0
  2303.       movew    #0x4400,a0@(comm)    | load first argument to fp0
  2304.       cmpiw    #0x8900,a0@(resp)    | check
  2305. !     movel    sp@(4),a0@
  2306.       movew    #0x4427,a0@(comm)
  2307.       .long    0x0c688900, 0xfff067f8
  2308. !     movel    sp@(8),a0@
  2309.       movew    #0x6400,a0@(comm)    | result to d0
  2310.       .long    0x0c688900, 0xfff067f8
  2311.       movel    a0@,d0
  2312. ***************
  2313. *** 45,52 ****
  2314. --- 45,59 ----
  2315.   |
  2316.   | written by Kai-Uwe Bloem (I5110401@dbstu1.bitnet).
  2317.   | Based on a 80x86 floating point packet from comp.os.minix, written by P.Housel
  2318. + |
  2319. + | Revision 1.2.3 michal 05-93 (ntomczak@vm.ucs.ualberta.ca)
  2320. + |   + code smoothing
  2321. + |
  2322.   | patched by Olaf Flebbe (flebbe@tat.physik.uni-tuebingen.de)
  2323.   |
  2324. + | Revision 1.2.2 olaf 05-93
  2325. + |   + fixed a bug with -0.
  2326. + |
  2327.   | Revision 1.2.1 olaf 12-92:
  2328.   |   + added support for NaN and Infinites
  2329.   |   + added support for -0
  2330. ***************
  2331. *** 67,93 ****
  2332.       moveml    d2-d5,sp@-
  2333.       moveml    a0@,d4/d5    | d4 = v, d5 = u
  2334.   
  2335.       movel    d5,d0        | d0 = u.exp
  2336.       swap    d0
  2337.       movew    d0,d2        | d2 = u.sign
  2338.       lsrw    #7,d0
  2339. -     andw    #0xff,d0    | kill sign bit
  2340.   
  2341.       movel    d4,d1        | d1 = v.exp
  2342.       swap    d1
  2343. !     eorw    d1,d2        | d2 = u.sign ^ v.sign (in bit 31)
  2344.       lsrw    #7,d1
  2345. -     andw    #0xff,d1    | kill sign bit
  2346.   
  2347. -     andl    #0x7fffff,d5    | remove exponent from u.mantissa
  2348. -     andl    #0x7fffff,d4    | remove exponent from v.mantissa
  2349.   |
  2350.   | Testing for NaN and Infinities
  2351.   |
  2352. !     cmpb    #0xff,d0
  2353.       beq    0f
  2354. !     cmpb    #0xff,d1
  2355.       bne    nospec
  2356.       bra    1f
  2357.   |    first operand is special
  2358. --- 74,101 ----
  2359.       moveml    d2-d5,sp@-
  2360.       moveml    a0@,d4/d5    | d4 = v, d5 = u
  2361.   
  2362. !     movel    #0x7fffff,d3
  2363.       movel    d5,d0        | d0 = u.exp
  2364. +     andl    d3,d5        | remove exponent from u.mantissa
  2365.       swap    d0
  2366.       movew    d0,d2        | d2 = u.sign
  2367. +     bclr    #15,d0        | kill sign bit
  2368.       lsrw    #7,d0
  2369.   
  2370.       movel    d4,d1        | d1 = v.exp
  2371. +     andl    d3,d4        | remove exponent from v.mantissa
  2372.       swap    d1
  2373. !     eorw    d1,d2        | d2 = u.sign ^ v.sign (in bit 15)
  2374. !     bclr    #15,d1        | kill sign bit
  2375.       lsrw    #7,d1
  2376.   
  2377.   |
  2378.   | Testing for NaN and Infinities
  2379.   |
  2380. !     moveq    #-1,d3
  2381. !     cmpb    d3,d0
  2382.       beq    0f
  2383. !     cmpb    d3,d1
  2384.       bne    nospec
  2385.       bra    1f
  2386.   |    first operand is special
  2387. ***************
  2388. *** 100,116 ****
  2389.       tstl    d4
  2390.       beq    retnan  | Inf * 0 == NaN
  2391.   
  2392. ! retinf:    tstl    d2
  2393. !     bpl    0f
  2394. !     movel    #0xff800000,d0
  2395.   return:    moveml    sp@+,d2-d5
  2396.       rts
  2397. ! 0:    movel    #0x7f800000,d0
  2398. !     bra    return    
  2399. ! retnan: movel    #0x7fffffff,d0
  2400.       bra    return
  2401.   |
  2402.   | v is special
  2403. --- 108,126 ----
  2404.       tstl    d4
  2405.       beq    retnan  | Inf * 0 == NaN
  2406.   
  2407. ! |
  2408. ! |    Return Infinity with correct sign
  2409. ! |
  2410. ! retinf: movel    #0xff000000,d0  | we will return #0xff800000 or #0x7f800000
  2411. !     lslw    #1,d2
  2412. !     roxrl   #1,d0        | shift in high bit as given by d2
  2413.   return:    moveml    sp@+,d2-d5
  2414.       rts
  2415. ! |
  2416. ! |    Return NaN
  2417. ! |
  2418. ! retnan: moveql    #-1,d0
  2419. !     lsrl    #1,d0        | 0x7fffffff -> d0
  2420.       bra    return
  2421.   |
  2422.   | v is special
  2423. ***************
  2424. *** 124,144 ****
  2425.       bra    retinf
  2426.   |
  2427.   | end of NaN and Inf.
  2428. ! |    
  2429. ! nospec:    subw    #8,sp        | multiplication accumulator
  2430.       tstw    d0        | check for zero exponent - no leading "1"
  2431. !     beq    0f
  2432. !     bset    #23,d5        | restore implied leading "1"
  2433. !     bra    1f
  2434. ! 0:    addw    #1,d0        | "normalize" exponent
  2435.   1:    tstl    d5
  2436.       beq    retz        | multiplying zero
  2437.   
  2438. -     tstw    d1        | check for zero exponent - no leading "1"
  2439. -     beq    0f
  2440.       bset    #23,d4        | restore implied leading "1"
  2441. !     bra    1f
  2442. ! 0:    addw    #1,d1        | "normalize" exponent
  2443.   1:    tstl    d4
  2444.       beq    retz        | multiply by zero
  2445.   
  2446. --- 134,154 ----
  2447.       bra    retinf
  2448.   |
  2449.   | end of NaN and Inf.
  2450. ! |
  2451. ! nospec:    bset    #23,d5        | restore implied leading "1"
  2452. !     subw    #8,sp        | multiplication accumulator
  2453.       tstw    d0        | check for zero exponent - no leading "1"
  2454. !     bne    1f
  2455. !     bclr    #23,d5        | remove it
  2456. !     addqw    #1,d0        | "normalize" exponent
  2457.   1:    tstl    d5
  2458.       beq    retz        | multiplying zero
  2459.   
  2460.       bset    #23,d4        | restore implied leading "1"
  2461. !     tstw    d1        | check for zero exponent - no leading "1"
  2462. !     bne    1f
  2463. !     bclr    #23,d4        | remove it
  2464. !     addqw    #1,d1        | "normalize" exponent
  2465.   1:    tstl    d4
  2466.       beq    retz        | multiply by zero
  2467.   
  2468. ***************
  2469. *** 172,179 ****
  2470.                   | [TOP 16 BITS SHOULD BE ZERO !]
  2471.       moveml    sp@(2),d4-d5    | get the 48 valid mantissa bits
  2472.       clrw    d5        | (pad to 64)
  2473.   2:
  2474. !     cmpl    #0x0000ffff,d4    | multiply (shift) until
  2475.       bhi    3f        |  1 in upper 16 result bits
  2476.       cmpw    #9,d0        | give up for denormalized numbers
  2477.       ble    3f
  2478. --- 182,191 ----
  2479.                   | [TOP 16 BITS SHOULD BE ZERO !]
  2480.       moveml    sp@(2),d4-d5    | get the 48 valid mantissa bits
  2481.       clrw    d5        | (pad to 64)
  2482. +     movel    #0x0000ffff,d3
  2483.   2:
  2484. !     cmpl    d3,d4        | multiply (shift) until
  2485.       bhi    3f        |  1 in upper 16 result bits
  2486.       cmpw    #9,d0        | give up for denormalized numbers
  2487.       ble    3f
  2488. ***************
  2489. *** 193,199 ****
  2490.   4:    addw    #8,sp        | remove accumulator from stack
  2491.       jmp    norm_sf        | (result in d4)
  2492.   
  2493. ! retz:    clrl    d0        | save zero as result
  2494.       addw    #8,sp
  2495.       moveml    sp@+,d2-d5
  2496.       rts            | no normalizing neccessary
  2497. --- 205,213 ----
  2498.   4:    addw    #8,sp        | remove accumulator from stack
  2499.       jmp    norm_sf        | (result in d4)
  2500.   
  2501. ! retz:    moveq    #0,d0        | save zero as result
  2502. !     lslw    #1,d2        | and set it sign as for d2
  2503. !     roxrl    #1,d0
  2504.       addw    #8,sp
  2505.       moveml    sp@+,d2-d5
  2506.       rts            | no normalizing neccessary
  2507. ===================================================================
  2508. RCS file: /net/acae127/home/bammi/etc/src/master/atari/co/_normdf.cpp,v
  2509. retrieving revision 1.7
  2510. diff -c -r1.7 _normdf.cpp
  2511. *** 1.7    1992/12/28 07:56:08
  2512. --- _normdf.cpp    1993/05/29 20:28:37
  2513. ***************
  2514. *** 7,12 ****
  2515. --- 7,18 ----
  2516.   |
  2517.   | written by Kai-Uwe Bloem (I5110401@dbstu1.bitnet).
  2518.   | Based on a 80x86 floating point packet from comp.os.minix, written by P.Housel
  2519. + |
  2520. + | Revision 1.6.3 michal 05-93 (ntomczak@vm.ucs.ualberta.ca)
  2521. + |  + restored and ensured future synchronization with errno codes
  2522. + |  + removed bogus error when normalizing legitimate zero
  2523. + |  + small mods to shave off few cycles
  2524. + |
  2525.   | patched by Olaf Flebbe (flebbe@tat.physik.uni-tuebingen.de)
  2526.   |
  2527.   | Revision 1.6.2 olaf 12-92:
  2528. ***************
  2529. *** 73,84 ****
  2530.       movel    a0@+,d0        | get exponent
  2531.       movel    a0@+,d2        | get sign
  2532.       bpl    0f        | or bit 31 to bit 15 for later tests
  2533. !     orw    #0x8000,d2
  2534.   0:    movel    a0@+,d1        | rounding information
  2535.   
  2536. !     cmpl    #0x7fff,d0    | test exponent
  2537.       bgt    oflow
  2538. !     cmpl    #-0x8000,d0
  2539.       blt    retz
  2540.   # endif
  2541.   
  2542. --- 79,92 ----
  2543.       movel    a0@+,d0        | get exponent
  2544.       movel    a0@+,d2        | get sign
  2545.       bpl    0f        | or bit 31 to bit 15 for later tests
  2546. !     bset    #15,d2
  2547.   0:    movel    a0@+,d1        | rounding information
  2548.   
  2549. !     movel    #0x7fff,d3
  2550. !     cmpl    d3,d0        | test exponent
  2551.       bgt    oflow
  2552. !     notl    d3        | #-0x8000 -> d3
  2553. !     cmpl    d3,d0
  2554.       blt    retz
  2555.   # endif
  2556.   
  2557. ***************
  2558. *** 90,96 ****
  2559.       orl    d5,d3
  2560.       bne    1f
  2561.       tstb    d1
  2562. !     beq    retz
  2563.   1:
  2564.       movel    d4,d3
  2565.       andl    #0xfffff000,d3    | fast shift, 16 bits ?
  2566. --- 98,104 ----
  2567.       orl    d5,d3
  2568.       bne    1f
  2569.       tstb    d1
  2570. !     beq    retzok
  2571.   1:
  2572.       movel    d4,d3
  2573.       andl    #0xfffff000,d3    | fast shift, 16 bits ?
  2574. ***************
  2575. *** 122,128 ****
  2576.   4:
  2577.       andb    #1,d2
  2578.       orb    d2,d1        | make least sig bit sticky
  2579. !     movel    #0xfff00000,d6
  2580.   5:    movel    d4,d3        | multiply (shift) until
  2581.       andl    d6,d3        | one in implied position
  2582.       bne    6f
  2583. --- 130,136 ----
  2584.   4:
  2585.       andb    #1,d2
  2586.       orb    d2,d1        | make least sig bit sticky
  2587. !     asrl    #1,d6        | #0xfff00000 -> d6
  2588.   5:    movel    d4,d3        | multiply (shift) until
  2589.       andl    d6,d3        | one in implied position
  2590.       bne    6f
  2591. ***************
  2592. *** 137,143 ****
  2593.       bge    8f        | round down - no action neccessary
  2594.       negb    d1
  2595.       bvc    7f        | round up
  2596. !         movew   d5,d1           | tie case - round to even 
  2597.                                   | dont need rounding bits any more
  2598.           andw    #1,d1           | check if even
  2599.           beq     8f              | mantissa is even - no action necessary
  2600. --- 145,151 ----
  2601.       bge    8f        | round down - no action neccessary
  2602.       negb    d1
  2603.       bvc    7f        | round up
  2604. !         movew   d5,d1           | tie case - round to even
  2605.                                   | dont need rounding bits any more
  2606.           andw    #1,d1           | check if even
  2607.           beq     8f              | mantissa is even - no action necessary
  2608. ***************
  2609. *** 151,170 ****
  2610.       addw    #1,d0        | correct exponent for denormalized numbers
  2611.       bra    2b
  2612.   0:    movel    d4,d3        | check for rounding overflow
  2613. !     andl    #0xffe00000,d3
  2614.       bne    2b        | go back and renormalize
  2615.   8:
  2616.       movel    d4,d3        | check if normalization caused an underflow
  2617.       orl    d5,d3
  2618.       beq    retz
  2619. !     cmpw    #0,d0        | check for exponent overflow or underflow
  2620.       blt    retz
  2621.       cmpw    #2047,d0
  2622.       bge    oflow
  2623.   
  2624. !     lslw    #4,d0        | re-position exponent
  2625. !     andw    #0x8000,d2    | sign bit
  2626. !     orw    d2,d0
  2627.       swap    d0        | map to upper word
  2628.       clrw    d0
  2629.       andl    #0x0fffff,d4    | top mantissa bits
  2630. --- 159,179 ----
  2631.       addw    #1,d0        | correct exponent for denormalized numbers
  2632.       bra    2b
  2633.   0:    movel    d4,d3        | check for rounding overflow
  2634. !     asll    #1,d6        | #0xffe00000 -> d3
  2635. !     andl    d6,d3
  2636.       bne    2b        | go back and renormalize
  2637.   8:
  2638.       movel    d4,d3        | check if normalization caused an underflow
  2639.       orl    d5,d3
  2640.       beq    retz
  2641. !     tstw    d0        | check for exponent overflow or underflow
  2642.       blt    retz
  2643.       cmpw    #2047,d0
  2644.       bge    oflow
  2645.   
  2646. !     lslw    #5,d0        | re-position exponent - one bit too high
  2647. !     lslw    #1,d2        | get X bit
  2648. !     roxrw    #1,d0        | shift it into sign position
  2649.       swap    d0        | map to upper word
  2650.       clrw    d0
  2651.       andl    #0x0fffff,d4    | top mantissa bits
  2652. ***************
  2653. *** 175,187 ****
  2654.       rts
  2655.   
  2656.   retz:
  2657. !     moveq    #ERANGE,d0
  2658.       Emove   d0,Errno
  2659. !     clrl    d0        | return zero value
  2660. !     clrl    d1
  2661. !     tstw    d2
  2662. !     bpl    0f        | -0
  2663. !     bset    #31,d0
  2664.   0:    moveml    sp@+,d2-d7
  2665.       rts
  2666.   
  2667. --- 184,196 ----
  2668.       rts
  2669.   
  2670.   retz:
  2671. !     moveq    #Erange,d0
  2672.       Emove   d0,Errno
  2673. ! retzok:
  2674. !     moveq    #0,d0        | return zero value
  2675. !     movel    d0,d1
  2676. !     lslw    #1,d2        | set value of extension
  2677. !     roxrl    #1,d0        | and move it to hight bit of d0
  2678.   0:    moveml    sp@+,d2-d7
  2679.       rts
  2680.   
  2681. ***************
  2682. *** 191,206 ****
  2683.       pea    Stderr
  2684.       jbsr    _fprintf    |
  2685.       addql    #8,a7        |
  2686. !     moveq    #ERANGE,d0
  2687.       Emove    d0,Errno
  2688.   #endif    ERROR_CHECK
  2689.   
  2690.   |    moveml    pc@(__infinitydf),d0-d1 | return infinity value
  2691.       moveml    __infinitydf,d0-d1 | return infinty value
  2692. !     andw    #0x8000,d2    | get sign bit of argument
  2693. !     swap    d2
  2694. !     clrw    d2
  2695. !     orl    d2,d0
  2696.       moveml    sp@+,d2-d7    | should really cause trap ?!? (mjr: why?)
  2697.       rts
  2698.   
  2699. --- 200,215 ----
  2700.       pea    Stderr
  2701.       jbsr    _fprintf    |
  2702.       addql    #8,a7        |
  2703. !     moveq    #Erange,d0
  2704.       Emove    d0,Errno
  2705.   #endif    ERROR_CHECK
  2706.   
  2707.   |    moveml    pc@(__infinitydf),d0-d1 | return infinity value
  2708.       moveml    __infinitydf,d0-d1 | return infinty value
  2709. !     tstw    d2
  2710. !     bpl    1f
  2711. !     bset    #31,d0
  2712. ! 1:
  2713.       moveml    sp@+,d2-d7    | should really cause trap ?!? (mjr: why?)
  2714.       rts
  2715.   
  2716. ===================================================================
  2717. RCS file: /net/acae127/home/bammi/etc/src/master/atari/co/_normsf.cpp,v
  2718. retrieving revision 1.5
  2719. diff -c -r1.5 _normsf.cpp
  2720. *** 1.5    1993/01/13 14:30:49
  2721. --- _normsf.cpp    1993/05/29 20:28:38
  2722. ***************
  2723. *** 7,12 ****
  2724. --- 7,18 ----
  2725.   |
  2726.   | written by Kai-Uwe Bloem (I5110401@dbstu1.bitnet).
  2727.   | Based on a 80x86 floating point packet from comp.os.minix, written by P.Housel
  2728. + |
  2729. + | Revision 1.4.4 michal 05-93 (ntomczak@vm.ucs.ualberta.ca)
  2730. + |  + restored and ensured future synchronization with errno codes
  2731. + |  + removed bogus error when normalizing legitimate zero
  2732. + |  + small mods to shave off few cycles
  2733. + |
  2734.   | patched by Olaf Flebbe (flebbe@tat.physik.uni-tuebingen.de)
  2735.   |
  2736.   | Revision 1.4.3 olaf 12-92:
  2737. ***************
  2738. *** 60,92 ****
  2739.   
  2740.       | internal entry for floating point package, saves time
  2741.       | d0=u.exp, d2=u.sign, d1=rounding bits, d4/d5=mantissa
  2742. !     | registers d2-d7 must be saved on the stack !
  2743.   norm_sf:
  2744.       tstl    d4        | rounding and u.mant == 0 ?
  2745.       bne    0f
  2746.       tstb    d1
  2747. !     beq    retz
  2748.   0:
  2749.       clrb    d2        | "sticky byte"
  2750. !     movel    #0xff000000,d5
  2751. ! 1:    tstw    d0        | divide (shift)
  2752.       ble    0f        |  denormalized number
  2753.       movel    d4,d3
  2754.       andl    d5,d3        |  or until no bits above 23
  2755.       beq    2f
  2756. ! 0:    addw    #1,d0        | increment exponent
  2757.       lsrl    #1,d4
  2758.       orb    d1,d2        | set "sticky"
  2759.       roxrb    #1,d1        | shift into rounding bits
  2760. !     bra    1b
  2761.   2:
  2762.       andb    #1,d2
  2763.       orb    d2,d1        | make least sig bit "sticky"
  2764. !     movel    #0xff800000,d5
  2765.   3:    movel    d4,d3        | multiply (shift) until
  2766.       andl    d5,d3        | one in "implied" position
  2767.       bne    4f
  2768. !     subw    #1,d0        | decrement exponent
  2769.       beq    4f        |  too small. store as denormalized number
  2770.       addb    d1,d1        | some doubt about this one *
  2771.       addxl    d4,d4
  2772. --- 66,98 ----
  2773.   
  2774.       | internal entry for floating point package, saves time
  2775.       | d0=u.exp, d2=u.sign, d1=rounding bits, d4/d5=mantissa
  2776. !     | registers d2-d5 must be saved on the stack !
  2777.   norm_sf:
  2778.       tstl    d4        | rounding and u.mant == 0 ?
  2779.       bne    0f
  2780.       tstb    d1
  2781. !     beq    retzok
  2782.   0:
  2783.       clrb    d2        | "sticky byte"
  2784. ! 1:    movel    #0xff000000,d5
  2785. ! 7:    tstw    d0        | divide (shift)
  2786.       ble    0f        |  denormalized number
  2787.       movel    d4,d3
  2788.       andl    d5,d3        |  or until no bits above 23
  2789.       beq    2f
  2790. ! 0:    addqw    #1,d0        | increment exponent
  2791.       lsrl    #1,d4
  2792.       orb    d1,d2        | set "sticky"
  2793.       roxrb    #1,d1        | shift into rounding bits
  2794. !     bra    7b
  2795.   2:
  2796.       andb    #1,d2
  2797.       orb    d2,d1        | make least sig bit "sticky"
  2798. !     asrl    #1,d5        | #0xff800000 -> d5
  2799.   3:    movel    d4,d3        | multiply (shift) until
  2800.       andl    d5,d3        | one in "implied" position
  2801.       bne    4f
  2802. !     subqw    #1,d0        | decrement exponent
  2803.       beq    4f        |  too small. store as denormalized number
  2804.       addb    d1,d1        | some doubt about this one *
  2805.       addxl    d4,d4
  2806. ***************
  2807. *** 98,104 ****
  2808.       bvc    5f        | round up
  2809.       movew   d4,d1           | tie case - round to even
  2810.                                   | dont need rounding bits any more
  2811. !     andw    #1,d1           | check if even        
  2812.       beq    6f              | mantissa is even - no action necessary
  2813.                                   | fall through
  2814.   
  2815. --- 104,110 ----
  2816.       bvc    5f        | round up
  2817.       movew   d4,d1           | tie case - round to even
  2818.                                   | dont need rounding bits any more
  2819. !     andw    #1,d1           | check if even
  2820.       beq    6f              | mantissa is even - no action necessary
  2821.                                   | fall through
  2822.   
  2823. ***************
  2824. *** 110,128 ****
  2825.       addw    #1,d0        | correct exponent for denormalized numbers
  2826.       bra    1b
  2827.   0:    movel    d4,d3        | check for rounding overflow
  2828. !     andl    #0xff000000,d3
  2829. !     bne    1b        | go back and renormalize
  2830.   6:
  2831.       tstl    d4        | check if normalization caused an underflow
  2832.       beq    retz
  2833. !     cmpw    #0,d0        | check for exponent overflow or underflow
  2834.       blt    retz
  2835.       cmpw    #255,d0
  2836.       bge    oflow
  2837.   
  2838. !     lslw    #7,d0        | re-position exponent
  2839. !     andw    #0x8000,d2    | sign bit
  2840. !     orw    d2,d0
  2841.       swap    d0        | map to upper word
  2842.       clrw    d0
  2843.       andl    #0x7fffff,d4    | top mantissa bits
  2844. --- 116,135 ----
  2845.       addw    #1,d0        | correct exponent for denormalized numbers
  2846.       bra    1b
  2847.   0:    movel    d4,d3        | check for rounding overflow
  2848. !     asll    #1,d5        | #0xff000000 -> d5
  2849. !     andl    d5,d3
  2850. !     bne    7b        | go back and renormalize
  2851.   6:
  2852.       tstl    d4        | check if normalization caused an underflow
  2853.       beq    retz
  2854. !     tstw    d0        | check for exponent overflow or underflow
  2855.       blt    retz
  2856.       cmpw    #255,d0
  2857.       bge    oflow
  2858.   
  2859. !     lslw    #8,d0        | re-position exponent - one bit too high
  2860. !     lslw    #1,d2        | get X bit
  2861. !     roxrw    #1,d0        | shift it into sign position
  2862.       swap    d0        | map to upper word
  2863.       clrw    d0
  2864.       andl    #0x7fffff,d4    | top mantissa bits
  2865. ***************
  2866. *** 130,163 ****
  2867.       moveml    sp@+,d2-d5
  2868.       rts
  2869.   
  2870. ! retz:    moveq    #ERANGE,d0
  2871.       Emove    d0,Errno
  2872. !     clrl    d0
  2873. !     tstw    d2
  2874. !     bpl    0f        | -0
  2875. !     bset    #31,d0
  2876. ! 0:    moveml    sp@+,d2-d5
  2877.       rts
  2878.   
  2879. ! oflow:    
  2880.   
  2881.   #ifdef    ERROR_CHECK
  2882. !     movel    d1,a7@-
  2883.       pea    pc@(LC0)
  2884.       pea    Stderr
  2885.       jbsr    _fprintf    |
  2886. !     addql    #8,a7        |
  2887. !     movel    a7@+,d1
  2888.   #endif    ERROR_CHECK
  2889.   
  2890.   |    movel    pc@(__infinitysf),d0    | return infinity value
  2891.       movel   __infinitysf,d0
  2892.   
  2893. !     btst    #15,d2        | transfer sign
  2894. !     beq    ofl_clear    | (mjr++)
  2895.       bset    #31,d0        |
  2896. -     moveml  sp@+,d2-d5
  2897. -     rts
  2898.   ofl_clear:
  2899.       moveml    sp@+,d2-d5    | should really cause trap ?!?
  2900.       rts
  2901. --- 137,168 ----
  2902.       moveml    sp@+,d2-d5
  2903.       rts
  2904.   
  2905. ! retz:    moveq    #Erange,d0
  2906.       Emove    d0,Errno
  2907. ! retzok:
  2908. !     moveq    #0,d0
  2909. !     lslw    #1,d2
  2910. !     roxrl    #1,d0        | sign of 0 is the same as of d2
  2911. !     moveml    sp@+,d2-d5
  2912.       rts
  2913.   
  2914. ! oflow:
  2915.   
  2916.   #ifdef    ERROR_CHECK
  2917. !     movel    d1,sp@-
  2918.       pea    pc@(LC0)
  2919.       pea    Stderr
  2920.       jbsr    _fprintf    |
  2921. !     addql    #8,sp        |
  2922. !     movel    sp@+,d1
  2923.   #endif    ERROR_CHECK
  2924.   
  2925.   |    movel    pc@(__infinitysf),d0    | return infinity value
  2926.       movel   __infinitysf,d0
  2927.   
  2928. !     tstw    d2        | transfer sign
  2929. !     bge    ofl_clear    | (mjr++)
  2930.       bset    #31,d0        |
  2931.   ofl_clear:
  2932.       moveml    sp@+,d2-d5    | should really cause trap ?!?
  2933.       rts
  2934. ===================================================================
  2935. RCS file: /net/acae127/home/bammi/etc/src/master/atari/co/_truncdf.cpp,v
  2936. retrieving revision 1.4
  2937. diff -c -r1.4 _truncdf.cpp
  2938. *** 1.4    1993/03/01 17:34:16
  2939. --- _truncdf.cpp    1993/05/29 20:28:40
  2940. ***************
  2941. *** 48,53 ****
  2942. --- 48,58 ----
  2943.   |
  2944.   | written by Kai-Uwe Bloem (I5110401@dbstu1.bitnet).
  2945.   | Based on a 80x86 floating point packet from comp.os.minix, written by P.Housel
  2946. + |
  2947. + | Revision 1.2.2 michal 05-93: (ntomczak@vm.ucs.ualberta.ca)
  2948. + |  + corrected bug in setting sign of returned Inf
  2949. + |  + code cleanup
  2950. + |
  2951.   | patched by Olaf Flebbe (flebbe@tat.physik.uni-tuebingen.de)
  2952.   |
  2953.   | Revision 1.2.1 olaf 12-92 :
  2954. ***************
  2955. *** 65,101 ****
  2956.   BIAS4    =    0x7F-1
  2957.   BIAS8    =    0x3FF-1
  2958.   
  2959. !     lea    sp@(4),a0    | parameter pointer
  2960.       moveml    d2-d5,sp@-    | save regs
  2961. -     moveml    a0@,d4-d5    | get number
  2962.   
  2963. !     movew    a0@,d0        | extract exponent
  2964.       movew    d0,d2        | extract sign
  2965.       lsrw    #4,d0
  2966. -     andw    #0x7ff,d0    | kill sign bit
  2967.       andl    #0x0fffff,d4    | remove exponent from mantissa
  2968.   |
  2969.   |
  2970.   |
  2971.       cmpw    #0x7ff,d0
  2972.       bne    nospec
  2973. !     orl    d4,d5
  2974.       bne    retnan
  2975. !     movel   #0x7f800000,d0
  2976. !     tstl    d4
  2977. !     bpl    return
  2978. !     bset    #31,d0
  2979.   return:    moveml    sp@+,d2-d5
  2980.       rts
  2981. ! retnan:    movel    #0x7fffffff,d0
  2982.       bra    return
  2983.   
  2984. ! nospec:    
  2985. !     tstw    d0        | check for zero exponent - no leading "1"
  2986. !     beq    0f        | for denormalized numbers
  2987.       bset    #20,d4        | restore implied leading "1"
  2988. !     bra    1f
  2989. ! 0:    addw    #1,d0        | "normalize" exponent
  2990.   1:
  2991.       addw    #BIAS4-BIAS8,d0    | adjust bias
  2992.   
  2993. --- 70,122 ----
  2994.   BIAS4    =    0x7F-1
  2995.   BIAS8    =    0x3FF-1
  2996.   
  2997. !     moveml    sp@(4),d0-d1    | get number
  2998.       moveml    d2-d5,sp@-    | save regs
  2999.   
  3000. !     movel    d0,d4        | save for norm_df
  3001. !     swap    d0        | extract exponent
  3002.       movew    d0,d2        | extract sign
  3003. +     bclr    #15,d0        | kill sign bit
  3004.       lsrw    #4,d0
  3005.       andl    #0x0fffff,d4    | remove exponent from mantissa
  3006.   |
  3007.   |
  3008.   |
  3009.       cmpw    #0x7ff,d0
  3010.       bne    nospec
  3011. !     orl    d4,d1
  3012.       bne    retnan
  3013. !     movel   #0xff00000,d0
  3014. !     lslw    #1,d2
  3015. !     roxrl    #1,d0
  3016.   return:    moveml    sp@+,d2-d5
  3017.       rts
  3018. ! retnan:    moveq    #-1,d0
  3019. !     lsrl    #1,d0        | #0x7fffffff -> d0
  3020.       bra    return
  3021.   
  3022. ! | Should we really return SNaN, which has a sign bit set accordingly??
  3023. ! | if yes, then the following code can be used instead -- mj
  3024. ! |
  3025. ! |    cmpw    #0x7ff,d0
  3026. ! |    bne    nospec
  3027. ! |    orl    d4,d1
  3028. ! |    bne    retnan
  3029. ! |    movel   #0xff00000,d0
  3030. ! |return:
  3031. ! |    lslw    #1,d2        | set X bit
  3032. ! |    roxrl    #1,d0        | roll in sign bit
  3033. ! |    moveml    sp@+,d2-d5
  3034. ! |    rts
  3035. ! |retnan:    moveq    #-1,d0
  3036. ! |    bra    return
  3037. ! nospec:    movel    d1,d5
  3038.       bset    #20,d4        | restore implied leading "1"
  3039. !     tstw    d0        | check for zero exponent - no leading "1"
  3040. !     bne    1f        | for denormalized numbers
  3041. !     bclr    #20,d4        | ... so do not do it but instead
  3042. !     addw    #1,d0        | "normalize" exponent
  3043.   1:
  3044.       addw    #BIAS4-BIAS8,d0    | adjust bias
  3045.   
  3046. ===================================================================
  3047. RCS file: /net/acae127/home/bammi/etc/src/master/atari/co/errbase.h,v
  3048. retrieving revision 1.1
  3049. diff -c -r1.1 errbase.h
  3050. *** 1.1    1992/10/09 20:35:29
  3051. --- errbase.h    1993/05/29 20:28:41
  3052. ***************
  3053. *** 2,12 ****
  3054.    * Errno defs to be included in *.ss floating point routines, from <errno.h>
  3055.    *   -- hyc@hanauma.jpl.nasa.gov, 9-17-92
  3056.    */
  3057.   
  3058.       .globl    _errno
  3059.   
  3060. ! EDOM    =    62
  3061. ! ERANGE    =    63
  3062.   
  3063.   #ifdef __MBASE__
  3064.   #define Errno    __MBASE__@(_errno)
  3065. --- 2,15 ----
  3066.    * Errno defs to be included in *.ss floating point routines, from <errno.h>
  3067.    *   -- hyc@hanauma.jpl.nasa.gov, 9-17-92
  3068.    */
  3069. + #define AssemB
  3070. + #include "errno.h"
  3071. + #undef  AssemB
  3072.   
  3073.       .globl    _errno
  3074.   
  3075. ! Edom    =    EDOM
  3076. ! Erange    =    ERANGE
  3077.   
  3078.   #ifdef __MBASE__
  3079.   #define Errno    __MBASE__@(_errno)
  3080. ===================================================================
  3081. RCS file: /net/acae127/home/bammi/etc/src/master/atari/co/frexp.cpp,v
  3082. retrieving revision 1.6
  3083. diff -c -r1.6 frexp.cpp
  3084. *** 1.6    1992/10/09 20:35:29
  3085. --- frexp.cpp    1993/05/29 20:28:43
  3086. ***************
  3087. *** 11,17 ****
  3088.    | ported to 68000 by Kai-Uwe Bloem, 12/89
  3089.    |  #1  original author: Peter S. Housel 9/21/88,01/17/89,03/19/89,5/24/89
  3090.    |  #2    added support for denormalized numbers            -kub-, 01/90
  3091. !  |  #   ported to gcc  ++jrb 04/90
  3092.    |-----------------------------------------------------------------------------
  3093.   
  3094.   BIAS8    =    0x3ff - 1
  3095. --- 11,19 ----
  3096.    | ported to 68000 by Kai-Uwe Bloem, 12/89
  3097.    |  #1  original author: Peter S. Housel 9/21/88,01/17/89,03/19/89,5/24/89
  3098.    |  #2    added support for denormalized numbers            -kub-, 01/90
  3099. !  |  #3  ported to gcc  ++jrb 04/90
  3100. !  |  #4  support for signed 0 - consistently with the rest - michal, 05/93
  3101. !  |      and some code cleanup
  3102.    |-----------------------------------------------------------------------------
  3103.   
  3104.   BIAS8    =    0x3ff - 1
  3105. ***************
  3106. *** 25,62 ****
  3107.   #else
  3108.       clrl    a0@
  3109.   #endif
  3110. !     tstl    sp@(4)        | 1st arg == 0 ?
  3111.       bne    nonzero
  3112. !     tstl    sp@(8)
  3113.       bne    nonzero
  3114. !     clrl    d0
  3115. !     clrl    d1
  3116. !     rts
  3117.   nonzero:
  3118. !     lea    sp@(4),a1
  3119. !     moveml    d2-d7,sp@-
  3120. ! 2:
  3121. !     movew    a1@,d0        | extract value.exp
  3122. !     movew    d0,d2        | extract value.sign    ++jrb
  3123.       lsrw    #4,d0
  3124. !     andw    #0x7ff,d0    | kill sign bit
  3125.       cmpw    #BIAS8,d0    | get out of loop if finally (a1) in [0.5,1.0)
  3126.       beq    3f
  3127.   
  3128. !     andw    #0x0f,a1@    | remove exponent from value.mantissa
  3129. !     tstw    d0        | check for zero exponent - no leading 1
  3130. !     beq    0f
  3131. !     orw    #0x10,a1@    | restore implied leading 1
  3132. !     bra    1f
  3133. ! 0:    addw    #1,d0
  3134. ! 1:
  3135.       movel    a1@,d1        | check for zero
  3136.       orl    a1@(4),d1
  3137.       beq    3f        | if zero, all done : exp = 0, num = 0.0
  3138.       subw    #BIAS8,d0    | remove bias
  3139. ! #ifdef __MSHORT__        
  3140. !     addw    d0,a0@        | add current exponent in
  3141.   #else
  3142.       extl    d0
  3143.       addl    d0,a0@        | add current exponent in
  3144. --- 27,69 ----
  3145.   #else
  3146.       clrl    a0@
  3147.   #endif
  3148. !     lea    sp@(4),a1    | sp@(4) -> a1 - an address of value
  3149. ! |                |   and a1@(8) - an address of *eptr
  3150. !     movel    a1@,d0        | keep value.sign
  3151. !     movel    d0,d1
  3152. !     bclr    #31,d1        | kill sign bit
  3153. !     tstl    d1        | 1st arg == 0 ?
  3154.       bne    nonzero
  3155. !     tstl    a1@(4)
  3156.       bne    nonzero
  3157. !     rts            | if 0 or -0 then d0 and d1 already set
  3158.   nonzero:
  3159. !     movel    d2,sp@-
  3160. ! 2:                | return here when looping
  3161. !     swap    d0        | sign and exponent into lower 16 bits
  3162. !     movew    d0,d2        | set d2 for norm_df
  3163. !     bclr    #15,d0        | kill sign bit
  3164.       lsrw    #4,d0
  3165.       cmpw    #BIAS8,d0    | get out of loop if finally (a1) in [0.5,1.0)
  3166.       beq    3f
  3167.   
  3168. !     moveq    #0x0f,d1    | remove exponent from value.mantissa
  3169. !     andb    d2,d1        | four upper bits of value in d1
  3170. !     bset    #4,d1        | implied leading 1
  3171. !     tstw    d0        | check for zero exponent
  3172. !     bne    1f
  3173. !     addqw    #1,d0
  3174. !     bclr    #4,d1        | nah, we do not need stinkin leadin 1
  3175. ! 1:    movew    d1,a1@        | save results of our efforts
  3176.       movel    a1@,d1        | check for zero
  3177.       orl    a1@(4),d1
  3178.       beq    3f        | if zero, all done : exp = 0, num = 0.0
  3179. !                 | sign of zero is correct
  3180.       subw    #BIAS8,d0    | remove bias
  3181. ! #ifdef __MSHORT__
  3182. !     addw    d0,a0        | add current exponent in
  3183.   #else
  3184.       extl    d0
  3185.       addl    d0,a0@        | add current exponent in
  3186. ***************
  3187. *** 68,79 ****
  3188.       moveml    d2-d7,sp@-    | ... need to copy with -mshort)
  3189.       moveml    a1@,d4-d5
  3190.       jmp    norm_df        | normalize result
  3191. ! L0:
  3192.       moveml    d0-d1,a1@
  3193.       bra    2b        | loop around to catch denormalized numbers
  3194.   3:
  3195.       moveml    a1@,d0-d1
  3196. !     moveml    sp@+,d2-d7
  3197.                   | d0-d1 has normalized mantissa
  3198.       rts
  3199.   
  3200. --- 75,87 ----
  3201.       moveml    d2-d7,sp@-    | ... need to copy with -mshort)
  3202.       moveml    a1@,d4-d5
  3203.       jmp    norm_df        | normalize result
  3204. ! L0:                | norm_df does not affect a0 or a1
  3205. ! |                | but it pops d2-d7
  3206.       moveml    d0-d1,a1@
  3207.       bra    2b        | loop around to catch denormalized numbers
  3208.   3:
  3209.       moveml    a1@,d0-d1
  3210. !     movel    sp@+,d2
  3211.                   | d0-d1 has normalized mantissa
  3212.       rts
  3213.   
  3214. ***************
  3215. *** 94,100 ****
  3216.   |#######################################################################
  3217.   | a0:    pointer to n
  3218.   |     sp@(12) address of resulting exponent (n)
  3219. !     
  3220.       .text; .even
  3221.   
  3222.   .globl _frexp
  3223. --- 102,108 ----
  3224.   |#######################################################################
  3225.   | a0:    pointer to n
  3226.   |     sp@(12) address of resulting exponent (n)
  3227.       .text; .even
  3228.   
  3229.   .globl _frexp
  3230. ***************
  3231. *** 161,171 ****
  3232.   |    bmi.b    www
  3233.   | is coded by
  3234.   |    .word    0x4a68,0xfff0,0x6bfa        | test
  3235. !     
  3236.       .text; .even
  3237.   
  3238.   .globl _frexp
  3239. !     
  3240.       tstl    sp@(4)        | 1st arg == 0 ?
  3241.       bne    nonzero
  3242.       tstl    sp@(8)
  3243. --- 169,179 ----
  3244.   |    bmi.b    www
  3245.   | is coded by
  3246.   |    .word    0x4a68,0xfff0,0x6bfa        | test
  3247.       .text; .even
  3248.   
  3249.   .globl _frexp
  3250.       tstl    sp@(4)        | 1st arg == 0 ?
  3251.       bne    nonzero
  3252.       tstl    sp@(8)
  3253. ===================================================================
  3254. RCS file: /net/acae127/home/bammi/etc/src/master/atari/co/ldexp.cpp,v
  3255. retrieving revision 1.6
  3256. diff -c -r1.6 ldexp.cpp
  3257. *** 1.6    1992/10/09 20:35:29
  3258. --- ldexp.cpp    1993/05/29 20:28:46
  3259. ***************
  3260. *** 42,47 ****
  3261. --- 42,48 ----
  3262.    |  #2    added support for denormalized numbers            -kub-, 01/90
  3263.    |  #3  ported to gcc  ++jrb  04/90
  3264.    |  #4  handle exponent overflow when ints are 32 bits        -kub-, 04/90
  3265. +  |  #5  make returned zero signed                  mj,  05/93
  3266.    |-----------------------------------------------------------------------------
  3267.   
  3268.       lea    sp@(4),a1
  3269. ***************
  3270. *** 49,64 ****
  3271.   
  3272.       movew    a1@,d0        | extract value.exp
  3273.       movew    d0,d2        | extract value.sign
  3274.       lsrw    #4,d0
  3275. -     andw    #0x7ff,d0    | kill sign bit
  3276.   
  3277. !     andw    #0x0f,a1@    | remove exponent from value.mantissa
  3278. !     tstw    d0        | check for zero exponent - no leading 1
  3279. !     beq    0f
  3280. !     orw    #0x10,a1@    | restore implied leading 1
  3281. !     bra    1f
  3282. ! 0:    addw    #1,d0
  3283. ! 1:
  3284.   #ifdef __MSHORT__
  3285.       addw    a1@(8),d0    | add in exponent
  3286.       extl    d0
  3287. --- 50,66 ----
  3288.   
  3289.       movew    a1@,d0        | extract value.exp
  3290.       movew    d0,d2        | extract value.sign
  3291. +     bclr    #15,d0        | kill sign bit
  3292.       lsrw    #4,d0
  3293.   
  3294. !     moveq    #0x0f,d3    | remove exponent from value.mantissa
  3295. !     andb    d2,d3        | four upper bits of value in d3
  3296. !     bset    #4,d3        | implied leading 1
  3297. !     tstw    d0        | check for zero exponent
  3298. !     bne    1f
  3299. !     addqw    #1,d0
  3300. !     bclr    #4,d3        | nah, we do not need stinkin leadin 1
  3301. ! 1:    movew    d3,a1@        | save results of our efforts
  3302.   #ifdef __MSHORT__
  3303.       addw    a1@(8),d0    | add in exponent
  3304.       extl    d0
  3305. ***************
  3306. *** 68,74 ****
  3307.   #endif
  3308.       cmpl    #-53,d0        | hmm. works only if 1 in implied position...
  3309.       ble    retz        | range error - underflow
  3310. !     cmpl    #2047,d0
  3311.       bge    rangerr        | range error - overflow
  3312.   
  3313.       clrw    d1        | zero rounding bits
  3314. --- 70,76 ----
  3315.   #endif
  3316.       cmpl    #-53,d0        | hmm. works only if 1 in implied position...
  3317.       ble    retz        | range error - underflow
  3318. !     cmpl    #0x7ff,d0
  3319.       bge    rangerr        | range error - overflow
  3320.   
  3321.       clrw    d1        | zero rounding bits
  3322. ***************
  3323. *** 77,89 ****
  3324.   
  3325.   retz:
  3326.       moveq    #0,d0        | zero return value
  3327. !     moveq    #0,d1
  3328.       jra    L0
  3329.   
  3330.   rangerr:
  3331.   
  3332.   #ifdef ERROR_CHECK
  3333. !     moveq    #ERANGE,d0
  3334.       Emove    d0,Errno
  3335.       pea    pc@(_Overflow)    | for printf
  3336.       pea    Stderr        |
  3337. --- 79,93 ----
  3338.   
  3339.   retz:
  3340.       moveq    #0,d0        | zero return value
  3341. !     movel    d0,d1
  3342. !     lslw    #1,d2        | transfer argument sign
  3343. !     roxrl    #1,d0
  3344.       jra    L0
  3345.   
  3346.   rangerr:
  3347.   
  3348.   #ifdef ERROR_CHECK
  3349. !     moveq    #Erange,d0
  3350.       Emove    d0,Errno
  3351.       pea    pc@(_Overflow)    | for printf
  3352.       pea    Stderr        |
  3353. ***************
  3354. *** 92,101 ****
  3355.   #endif ERROR_CHECK
  3356.   
  3357.       moveml    __infinitydf,d0-d1 | return HUGE_VAL (same as in <math.h>)
  3358. !     andw    #0x8000,d2    | get sign bit of argument
  3359. !     swap    d2
  3360. !     clrw    d2
  3361. !     orl    d2,d0
  3362.   L0:
  3363.       moveml    sp@+,d2-d7    | pop saved reggies
  3364.       rts
  3365. --- 96,104 ----
  3366.   #endif ERROR_CHECK
  3367.   
  3368.       moveml    __infinitydf,d0-d1 | return HUGE_VAL (same as in <math.h>)
  3369. !     tstw    d2
  3370. !     bge    L0
  3371. !     bset    #31,d0
  3372.   L0:
  3373.       moveml    sp@+,d2-d7    | pop saved reggies
  3374.       rts
  3375. ***************
  3376. *** 201,212 ****
  3377.   error_plus:
  3378.       swap    d0
  3379.       moveml    d0-d1,a7@-    | print error message
  3380. !     moveq    #ERANGE,d0    | Overflow: errno = ERANGE
  3381.       Emove    d0,Errno
  3382.       pea    pc@(_Domain)    | for printf
  3383.       bra    error_exit    |
  3384.   error_nan:
  3385. !     moveq    #EDOM,d0    | NAN => errno = EDOM
  3386.       Emove    d0,Errno
  3387.       moveml    a0@(24),d0-d1    | result = +inf
  3388.       moveml    d0-d1,a7@-    | print error message
  3389. --- 204,215 ----
  3390.   error_plus:
  3391.       swap    d0
  3392.       moveml    d0-d1,a7@-    | print error message
  3393. !     moveq    #Erange,d0    | Overflow: errno = ERANGE
  3394.       Emove    d0,Errno
  3395.       pea    pc@(_Domain)    | for printf
  3396.       bra    error_exit    |
  3397.   error_nan:
  3398. !     moveq    #Edom,d0    | NAN => errno = EDOM
  3399.       Emove    d0,Errno
  3400.       moveml    a0@(24),d0-d1    | result = +inf
  3401.       moveml    d0-d1,a7@-    | print error message
  3402. ===================================================================
  3403. RCS file: /net/acae127/home/bammi/etc/src/master/atari/co/modf.cpp,v
  3404. retrieving revision 1.2
  3405. diff -c -r1.2 modf.cpp
  3406. *** 1.2    1992/10/09 20:35:29
  3407. --- modf.cpp    1993/05/29 20:28:48
  3408. ***************
  3409. *** 1,18 ****
  3410.   #if !defined (__M68881__) && !defined (sfp004)
  3411.   
  3412.    | take floating point to integer and fractional pieces
  3413. !  | 
  3414.    | C interface
  3415.    |  double modf( double value, double *iptr)
  3416.    |  returns fractional part of value
  3417.    |       in *iptr returns the integral part
  3418.    |       such that (*iptr + fractional) == value
  3419. !  | 
  3420.    |-----------------------------------------------------------------------------
  3421.    | ported to 68000 by Kai-Uwe Bloem, 12/89
  3422.    |  #1  original author: Peter S. Housel 9/21/88,01/17/89,03/19/89,5/24/89
  3423.    |  #2  replaced shifts by swap if possible for speed increase    -kub-, 01/90
  3424.    |  #3  ported to gcc ++jrb 03/90
  3425.    |-----------------------------------------------------------------------------
  3426.   
  3427.   BIAS8    =    0x3ff - 1
  3428. --- 1,20 ----
  3429.   #if !defined (__M68881__) && !defined (sfp004)
  3430.   
  3431.    | take floating point to integer and fractional pieces
  3432. !  |
  3433.    | C interface
  3434.    |  double modf( double value, double *iptr)
  3435.    |  returns fractional part of value
  3436.    |       in *iptr returns the integral part
  3437.    |       such that (*iptr + fractional) == value
  3438. !  |
  3439.    |-----------------------------------------------------------------------------
  3440.    | ported to 68000 by Kai-Uwe Bloem, 12/89
  3441.    |  #1  original author: Peter S. Housel 9/21/88,01/17/89,03/19/89,5/24/89
  3442.    |  #2  replaced shifts by swap if possible for speed increase    -kub-, 01/90
  3443.    |  #3  ported to gcc ++jrb 03/90
  3444. +  |  #4  replaced by a completely new, smaller and faster implementation,
  3445. +  |        Michal Jaegermann, ntomczak@vm.ucs.ualberta.ca - 05/93
  3446.    |-----------------------------------------------------------------------------
  3447.   
  3448.   BIAS8    =    0x3ff - 1
  3449. ***************
  3450. *** 21,104 ****
  3451.       .globl _modf
  3452.   _modf:
  3453.       lea    sp@(4),a0    | a0 -> float argument
  3454. -     movel    sp@(12),a1    | a1 -> ipart result
  3455.       moveml    d2-d7,sp@-    | save d2-d7
  3456.   
  3457. !     movew    a0@,d0        | extract value.exp
  3458. !     movew    d0,d2        | extract value.sign
  3459. !     lsrw    #4,d0
  3460. !     andw    #0x7ff,d0    | kill sign bit
  3461. !     cmpw    #BIAS8,d0
  3462. !     bge    1f        | fabs(value) >= 1.0
  3463. !     clrl    a1@        | store zero as the integer part
  3464. !     clrl    a1@(4)
  3465. !     moveml    a0@,d0-d1    | return entire value as fractional part
  3466. !     jra    L0
  3467.   
  3468.   1:
  3469. !     cmpw    #BIAS8+53,d0    | all integer, with no fractional part ?
  3470. !     blt    2f        | no, mixed
  3471.   
  3472. !     movel    a0@,a1@        | store entire value as the integer part
  3473. !     movel    a0@(4),a1@(4)
  3474.       moveq    #0,d0        | return zero as fractional part
  3475. !     moveq    #0,d1
  3476. ! L0:
  3477. !     moveml    sp@+,d2-d7    | restore saved d2-d7
  3478. !     rts
  3479.   2:
  3480. ! |    moveml    d3-d7,sp@-    | save some registers (d2 is pushed already)
  3481. !     moveml    a0@,d4-d5    | get value
  3482. !     andl    #0x0fffff,d4    | remove exponent from value.mantissa
  3483. !     orl    #0x100000,d4    | restore implied leading "1"
  3484.   
  3485. !     moveq    #0,d6        | zero fractional part
  3486. !     moveq    #0,d7
  3487.   3:
  3488. !     cmpw    #BIAS8+37,d0    | fast shift, 16 bits ?
  3489. !     bgt    4f
  3490. !     movew    d6,d7        | shift down 16 bits
  3491. !     movew    d5,d6
  3492. !     movew    d4,d5
  3493. !     clrw    d4
  3494. !     swap    d7
  3495. !     swap    d6
  3496. !     swap    d5
  3497. !     swap    d4
  3498. !     addw    #16,d0
  3499. !     bra    3b
  3500.   4:
  3501. !     cmpw    #BIAS8+53,d0    | done ?
  3502. !     bge    5f
  3503. !     lsrl    #1,d4        | shift integer part
  3504. !     roxrl    #1,d5
  3505. !     roxrl    #1,d6        | shift high bit into fractional part
  3506. !     roxrl    #1,d7
  3507. !     addw    #1,d0        | increment ipart exponent
  3508. !     bra    4b        | keep shifting
  3509. ! 5:
  3510. !     | normalize ipart (all values are in correct reggies)
  3511. !      | save  a1, save d2-d7 that norm_df will pop
  3512. !     movel    a1,sp@-
  3513. !     pea    L1        | set up return address
  3514. !     moveml    d2-d7,sp@-    | norm_df will pop this
  3515. !     clrw    d1
  3516. !     jmp    norm_df        | go do it
  3517. ! L1:                | norm_df will rts to here
  3518. !     movel    sp@+,a1        | pop saved a1
  3519. !     moveml    d0-d1,a1@    | store result into ipart
  3520. !     
  3521. !     | norm fractional part
  3522. !     movel    d6,d4        | get frac into d4/d5
  3523. !     movel    d7,d5
  3524.       clrw    d1        | rounding = 0
  3525. !     movew    #BIAS8-11,d0    | set frac part exponent, sign already in d2
  3526. !     jmp    norm_df        | norm_df will pop d2/d7 we save before
  3527.                   | it will return to our caller via rts
  3528.                   | with result in d0-d1
  3529.   
  3530. --- 23,88 ----
  3531.       .globl _modf
  3532.   _modf:
  3533.       lea    sp@(4),a0    | a0 -> float argument
  3534.       moveml    d2-d7,sp@-    | save d2-d7
  3535. +     moveml    a0@+,d0-d1
  3536. +     movel   a0@,a1        | a1 -> ipart result
  3537.   
  3538. !     movel    d0,d2        | calculate exponent
  3539. !     swap    d2
  3540. !     bclr    #15,d2        | kill sign bit
  3541. !     lsrw    #4,d2        | exponent in lower 12 bits of d2
  3542. !     cmpw    #BIAS8,d2
  3543. !     bgt    1f        | fabs(value) >= 1.0
  3544. ! |                | return entire value as fractional part
  3545. !     clrl    a1@+        | d0, d1 already ok
  3546. !     clrl    a1@        | make integer part 0
  3547.   
  3548. + 0:
  3549. +     moveml    sp@+,d2-d7    | restore saved d2-d7
  3550. +     rts
  3551.   1:
  3552. !     movew    #BIAS8+53,d3
  3553. !     subw    d2,d3        | compute position of "binary point"
  3554. !     bgt    2f        | branch if we do have fractional part
  3555.   
  3556. !     moveml  d0-d1,a1@    | store entire value as the integer part
  3557.       moveq    #0,d0        | return zero as fractional part
  3558. !     movel    d0,d1
  3559. !     jra    0b
  3560.   2:
  3561. !     movel    d1,d5        | save for computation of fractional part
  3562.   
  3563. !     moveq    #32,d6
  3564. !     cmpw    d6,d3
  3565. !     blt    3f        | jump if "binary point" in a lower part
  3566. !     movel    d0,d4
  3567. !     subw    d6,d3
  3568. !     moveq    #0,d6        | compute mask for splitting
  3569. !     bset    d3,d6
  3570. !     negl    d6
  3571. !     andl    d6,d0        | this is integer part
  3572. !     moveq    #0,d1
  3573. !     notl    d6
  3574. !     andl    d6,d4        | and denormalized fractional part
  3575. !     jra    4f
  3576.   3:
  3577. !     moveq    #0,d6        | splitting on lower part
  3578. !     bset    d3,d6
  3579. !     negl    d6
  3580. !     andl    d6,d1        | this is integer part
  3581. !     moveq    #0,d4        | nothing in an upper fraction
  3582. !     notl    d6
  3583. !     andl    d6,d5        | and clear those unneded bits
  3584.   4:
  3585. !     moveml    d0-d1,a1@    | store computed integer part
  3586. !     swap    d0
  3587. !     exg    d0,d2        | set registers for norm_df
  3588.       clrw    d1        | rounding = 0
  3589. ! |                | normalize fractional part
  3590. !     jmp    norm_df        | norm_df will pop d2/d7 we saved before
  3591.                   | it will return to our caller via rts
  3592.                   | with result in d0-d1
  3593.   
  3594. ***************
  3595. *** 109,115 ****
  3596.   |       manually optimized by Michael Ritzert
  3597.   |
  3598.   |    double modf( double X, double * IP )
  3599. ! |    
  3600.   |    30.11.92
  3601.   |    ritzert@dfg.dbp.de
  3602.   |
  3603. --- 93,99 ----
  3604.   |       manually optimized by Michael Ritzert
  3605.   |
  3606.   |    double modf( double X, double * IP )
  3607. ! |
  3608.   |    30.11.92
  3609.   |    ritzert@dfg.dbp.de
  3610.   |
  3611.